Skip to content

[core] LocalServer does not report errors correctly #488

Closed
@sebsto

Description

@sebsto

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]

Metadata

Metadata

Assignees

Labels

kind/bugFeature doesn't work as expected.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions