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

Đang mở
#11 10 bình luận 12 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Go
Star
1.1k
Fork
118
Merge trung bình
42 phút
Pull request đã merge (30 ngày)
2

Mô tả

### 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`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with samcli/local/rapid/init.go around lines 482-486 and compare the header setup with the Rust runtime's lambda/src/types.rs lines 123-139. Run sam local start-api with the provided AWS Labs Rust runtime scenario; done means the local Lambda receives the expected headers and executes without the missing-key panic.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, docker, go, rust
Lĩnh vực
api, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.