-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
area/local/start-apisam local start-api commandsam local start-api commandstage/needs-investigationRequires a deeper investigationRequires a deeper investigationtype/bug
Description
Description:
When using an HttpApi event type for a Lambda function in a SAM template and running it locally, sam local uses a stageVariables
key with a null
value, which breaks deserialization for the Rust Lambda runtime and does not map to what API Gateway actually sends.
See awslabs/aws-lambda-rust-runtime#365 for more information on the Rust runtime side.
Steps to reproduce:
- Use
sam init
to create a new project - Select Zip, Python3.9, and Hello World example
- Modify the template.yaml file to use HttpApi instead of Api
- Modify the function code to display the event payload
- Run
sam local start-api
- Invoke the local API
- Notice the
stageVariables
field with a value ofnull
Observed result:
Here is a sample payload sent to the Lambda function from sam local start-api
:
{
"headers": {
"accept": "*/*",
"content-length": "0",
"host": "xxx.execute-api.us-east-1.amazonaws.com",
"user-agent": "curl/7.64.1",
"x-amzn-trace-id": "Root=1-5eb33c07-de25b420912dee103a5db434",
"x-forwarded-for": "65.78.31.245",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"isBase64Encoded": false,
"rawPath": "/",
"rawQueryString": "",
"requestContext": {
"accountId": "123456789012",
"apiId": "xxx",
"domainName": "xxx.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "xxx",
"http": {
"method": "GET",
"path": "/",
"protocol": "HTTP/1.1",
"sourceIp": "65.78.31.245",
"userAgent": "curl/7.64.1"
},
"requestId": "MIZRNhJtIAMEMDw=",
"routeKey": "$default",
"stage": "$default",
"time": "06/May/2020:22:36:55 +0000",
"timeEpoch": 1588804615616
},
"routeKey": "$default",
"version": "2.0"
}
Expected result:
stageVariables
would either be missing or contain an empty object.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Ubuntu 20.04
sam --version
: 1.34.1- AWS region: eu-north-1
Metadata
Metadata
Assignees
Labels
area/local/start-apisam local start-api commandsam local start-api commandstage/needs-investigationRequires a deeper investigationRequires a deeper investigationtype/bug