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

Hardcoded function name

オープン
#43 コメント 0 件 リアクション 5 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Go
スター
1.1k
フォーク
118
平均マージ
42分
マージ済み PR(30日)
2

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

RIE ウェブサーバーが関数名をハードコードしている cmd/aws-lambda-rie/http.go から始め、エンドポイントの動作を Lambda Invoke API のドキュメントと比較します。AWS_LAMBDA_FUNCTION_NAME がエンドポイントにどのような影響を与えるべきかを確認し、それが存在しない場合もデフォルトが function のままであることを確認します。完了の条件は、設定した名前とデフォルトの名前の両方が、ドキュメントに記載された呼び出しリクエストで機能することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, go
領域
api, cloud
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。