Skip to content

[core] LocalServer does not report errors correctly #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebsto opened this issue Feb 27, 2025 · 0 comments · Fixed by #489
Closed

[core] LocalServer does not report errors correctly #488

sebsto opened this issue Feb 27, 2025 · 0 comments · Fixed by #489
Assignees
Labels
kind/bug Feature doesn't work as expected.
Milestone

Comments

@sebsto
Copy link
Contributor

sebsto commented Feb 27, 2025

Expected behavior

The LocalLambdaServer used for testing does not report errors to the caller correctly.

  • the server should capture the error POSTed by the LambdaRuntime and forward it to the client
  • the server should close the TCP connection

Actual behavior

  1. The server does not report the error back to the client
  2. The server does not close the connection and the curl client stays blocked.

Steps to reproduce

cd Examples/APIGateway
LOG_LEVEL=trace swift run 

In another terminal, send an invalid payload:

curl --header 'Content-Type: application/json' --data "{}" --verbose http://127.0.0.1:7000/invoke 

If possible, minimal yet complete reproducer code (or URL to code)

APIGateway example

What version of this project (swift-aws-lambda-runtime) are you using?

main

Swift version

n/a

Amazon Linux 2 docker image version

n/a

Diagnostic

Diagnostic

Server trace:

2025-02-27T17:36:12+0100 debug LambdaRuntime : [AWSLambdaRuntimeCore] LambdaRuntime initialized
2025-02-27T17:36:12+0100 info LocalServer : host="127.0.0.1" port=7000 [AWSLambdaRuntimeCore] Server started and listening
2025-02-27T17:36:12+0100 trace LambdaRuntime : lambda_ip=127.0.0.1 lambda_port=7000 [AWSLambdaRuntimeCore] Connection to control plane created
2025-02-27T17:36:12+0100 trace LocalServer : [AWSLambdaRuntimeCore] Handling a new connection
2025-02-27T17:36:12+0100 trace LocalServer : URI=GET /2018-06-01/runtime/invocation/next [AWSLambdaRuntimeCore] Processing request
2025-02-27T17:36:12+0100 trace LocalServer : [AWSLambdaRuntimeCore] /next waiting for /invoke
2025-02-27T17:36:38+0100 trace LocalServer : [AWSLambdaRuntimeCore] Handling a new connection
2025-02-27T17:36:38+0100 trace LocalServer : Body={} URI=POST /invoke [AWSLambdaRuntimeCore] Processing request
2025-02-27T17:36:38+0100 trace LocalServer : requestID=544640702971583 [AWSLambdaRuntimeCore] /invoke received invocation
2025-02-27T17:36:38+0100 trace LocalServer : requestId=544640702971583 [AWSLambdaRuntimeCore] /next retrieved invocation
2025-02-27T17:36:38+0100 trace LocalServer : requestId=544640702971583 [AWSLambdaRuntimeCore] Writing response
2025-02-27T17:36:38+0100 trace LocalServer : Body={"errorType":"FunctionError","errorMessage":"keyNotFound(CodingKeys(stringValue: \"version\", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: \"No value associated with key CodingKeys(stringValue: \\\"version\\\", intValue: nil) (\\\"version\\\").\", underlyingError: nil))"} URI=POST /2018-06-01/runtime/invocation/544640702971583/error [AWSLambdaRuntimeCore] Processing request
2025-02-27T17:36:38+0100 trace LocalServer : requestId= [AWSLambdaRuntimeCore] Writing response
2025-02-27T17:36:38+0100 trace LambdaRuntime : [AWSLambdaRuntimeCore] Close lambda runtime client
2025-02-27T17:36:38+0100 trace LocalServer : [AWSLambdaRuntimeCore] Done handling the connection

Client Trace

curl --header 'Content-Type: application/json' --data "{}" --verbose http://127.0.0.1:7000/invoke            130 ↵
*   Trying 127.0.0.1:7000...
* Connected to 127.0.0.1 (127.0.0.1) port 7000
> POST /invoke HTTP/1.1
> Host: 127.0.0.1:7000
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 2
> 
* upload completely sent off: 2 bytes

[BLOCKED - CURL DOES NOT RETURN]
@sebsto sebsto added this to the 2.0 milestone Feb 27, 2025
@sebsto sebsto self-assigned this Feb 27, 2025
@sebsto sebsto added the kind/bug Feature doesn't work as expected. label Feb 27, 2025
sebsto pushed a commit that referenced this issue Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Feature doesn't work as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant