aws / aws/aws-lambda-runtime-interface-emulator

Hardcoded function name

Đang mở
#43 0 bình luận 5 reaction 0 người được giao Xem trên GitHub
enhancement
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ả

I'm not sure if this is a bug or a feature (request). I'll let someone else decide which it is.

The [Lambda invoke API docs](https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_RequestSyntax) say the endpoint path should be `/2015-03-31/functions/FunctionName/invocations` where `FunctionName` is the name of the function being invoked.

The [RIE web server hardcods the function name to `function`](https://github.com/aws/aws-lambda-runtime-interface-emulator/blob/ce45546/cmd/aws-lambda-rie/http.go#L18). When invoking a function by calling the documented `curl` call `curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'` everything works great.

If someone combines a container based Lambda using the RIE and the Step Function Local and the step function contains a different function name, say `myFunction` they could easily lose an afternoon debugging their stuff. Step Function Local logs an exception based on the 404 response, but the RIE logs show no requests being received. After checking the Step Function Local config docs, reviewing the step function multiple times, reviewing the Lambda API docs and busting out wireshark the dev may pick through the RIE code. Eventually they would discover the cause of this bug. Less than a minute after changing the value of the Lambda ARN in their step function, everything works.

Rather than forcing devs to use a fixed name in their step function, I propose that if the `AWS_LAMBDA_FUNCTION_NAME` environment variable is set, then that is the value used in the endpoint path. If the environment variable isn't present then `function` is used as the default value. This might save some poor developers many hours of swearing at their code.

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

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

Hướng nghiên cứu

Start in cmd/aws-lambda-rie/http.go, where the RIE web server hardcodes the function name, and compare the endpoint behavior with the Lambda Invoke API documentation. Verify how AWS_LAMBDA_FUNCTION_NAME should affect the endpoint and confirm that the default remains function when it is absent; done means both configured and default names work with the documented invocation request.

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, go
Lĩnh vực
api, cloud
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
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.