aws / aws/aws-lambda-runtime-interface-emulator
`sam local start-api` broken due to missing `lambda-runtime-invoked-function-arn` header since v1.13.0
- Lingua principale
- Go
- Stelle
- 1.1k
- Fork
- 118
- Merge medio
- 42m
- PR unite (30g)
- 2
Descrizione
### Description:
Up to version v1.12.0, I was able to test my API Gateway REST API using `sam local start-api` with a Lambda built on top of https://github.com/awslabs/aws-lambda-rust-runtime. However, this functionality stopped working in v1.13.0 due to the missing `lambda-runtime-invoked-function-arn` header that the runtime expects:
```
2020-12-04 17:54:54,881 | Found one Lambda function with name 'ApiFunction'
2020-12-04 17:54:54,881 | Invoking ignored (provided)
2020-12-04 17:54:54,881 | Environment variables overrides data is standard format
2020-12-04 17:54:54,881 | Loading AWS credentials from session with profile 'None'
2020-12-04 17:54:54,896 | Resolving code path. Cwd=/Users/daramos/...[redacted], CodeUri=.aws-sam/build-backend/ApiFunction
2020-12-04 17:54:54,897 | Resolved absolute path to code is /Users/daramos/...[redacted].../.aws-sam/build-backend/ApiFunction
2020-12-04 17:54:54,897 | Code /Users/daramos/...[redacted].../.aws-sam/build-backend/ApiFunction is not a zip/jar file
2020-12-04 17:54:54,940 | Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-provided:rapid-1.13.0.
2020-12-04 17:54:54,940 | Mounting /Users/daramos/Documents/Projects/...[redacted].../.aws-sam/build-backend/ApiFunction as /var/task:ro,delegated inside runtime container
2020-12-04 17:54:55,581 | Starting a timer for 3 seconds for function 'ApiFunction'
START RequestId: 5d85e30d-cda5-47dc-a1a6-4ed2ed87268c Version: $LATEST
thread 'main' panicked at 'no entry found for key "lambda-runtime-invoked-function-arn"', /Users/daramos/.cargo/git/checkouts/aws-lambda-rust-runtime-7c865cce90132439/13aa8f0/lambda/src/types.rs:131:35
```
The code runs fine on production AWS Lambda, so I believe this is a bug in the SAM CLI's local emulation, not in the Rust runtime. For reference, the runtime expects several headers to be provided by Lambda:
https://github.com/awslabs/aws-lambda-rust-runtime/blob/13aa8f01813e6949ca91aedafb286591fdf32217/lambda/src/types.rs#L123-L139
It looks like aws/aws-sam-cli#2425 may have introduced this regression (cc @sriram-mv). The code that previously set these headers was removed in that PR:
https://github.com/aws/aws-sam-cli/blob/559e4a564ba37906f2081c0de415b39bc9b2c3c1/samcli/local/rapid/init.go#L482-L486
### Steps to reproduce:
Use `sam local start-api` to test a REST API locally. In my case, using AWS Labs's Rust runtime.
### Observed result:
Lambda function panics due to missing headers (the same Lambda works fine on AWS).
### Expected result:
Lambda should execute without error.
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Mac OS 10.15.7
2. `sam --version`: 1.13.0 (also tested on 1.13.2 and latest `develop` HEAD).
`Add --debug flag to command you are running`
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con samcli/local/rapid/init.go intorno alle righe 482-486 e confronta la configurazione degli header con le righe 123-139 di lambda/src/types.rs del runtime Rust. Esegui sam local start-api con lo scenario fornito del runtime Rust di AWS Labs; il lavoro è completato quando la Lambda locale riceve gli header attesi ed esegue senza il panic dovuto a una chiave mancante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, docker, go, rust
- Ambito
- api, devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100