On docs/advanced/evaluation_functions/local.md (published at https://docs.lambdafeedback.com/advanced/evaluation_functions/local/) the docker run command and the example request are inconsistent, so following the page as written always fails.
The page gives:
docker run --rm -d --name eval-function -p 9000:8080 eval-tmp
then tells you to POST to http://localhost:9000/2015-03-31/functions/function/invocations with:
{ "headers": { "command": "eval" }, "body": { "response": "a", "answer": "a", "params": {} } }
Following that exactly returns {"error":{"message":"invalid method"}}.
Why
The base image entrypoint only starts the AWS Lambda Runtime Interface Emulator when AWS_LAMBDA_RIE is set:
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ] && [ -n "${AWS_LAMBDA_RIE}" ]; then
exec aws-lambda-rie "$@"
else
exec "$@"
fi
With the documented docker run that variable is unset, so Shimmy runs in standalone HTTP mode ("detected standalone environment" in the logs) and the /2015-03-31/... path does not exist. The documented endpoint belongs to the emulator, which the documented command never starts.
Two further problems apply even once the emulator is enabled:
body must be a JSON-encoded string, not an object. As an object the RIE returns json: cannot unmarshal object into Go struct field APIGatewayV2HTTPRequest.body of type string.
- The envelope needs
requestContext.http.method set to POST, otherwise Shimmy returns invalid method.
Suggested fix
Document the standalone shape as the default, since it matches the docker run command already on the page and is much simpler:
docker run --rm -d --name eval-function -p 9000:8080 eval-tmp
POST http://localhost:9000/
command: eval
Content-Type: application/json
{ "response": "a", "answer": "a", "params": {} }
Response: {"command":"eval","result":{...}}. GET /health also works.
Then, if the Lambda-emulator path is still worth documenting (for reproducing AWS behaviour), show it as a separate section with the two corrections:
docker run --rm -d --name eval-function -e AWS_LAMBDA_RIE=1 -p 9000:8080 eval-tmp
{
"version": "2.0",
"rawPath": "/",
"requestContext": { "http": { "method": "POST", "path": "/" } },
"headers": { "command": "eval", "content-type": "application/json" },
"body": "{\"response\":\"a\",\"answer\":\"a\",\"params\":{}}",
"isBase64Encoded": false
}
Both forms verified against a Python evaluation function built from the current boilerplate; the standalone form returns 200 with the result, and the corrected envelope returns statusCode: 200 with the result JSON-encoded in body.
On
docs/advanced/evaluation_functions/local.md(published at https://docs.lambdafeedback.com/advanced/evaluation_functions/local/) thedocker runcommand and the example request are inconsistent, so following the page as written always fails.The page gives:
then tells you to POST to
http://localhost:9000/2015-03-31/functions/function/invocationswith:{ "headers": { "command": "eval" }, "body": { "response": "a", "answer": "a", "params": {} } }Following that exactly returns
{"error":{"message":"invalid method"}}.Why
The base image entrypoint only starts the AWS Lambda Runtime Interface Emulator when
AWS_LAMBDA_RIEis set:With the documented
docker runthat variable is unset, so Shimmy runs in standalone HTTP mode ("detected standalone environment" in the logs) and the/2015-03-31/...path does not exist. The documented endpoint belongs to the emulator, which the documented command never starts.Two further problems apply even once the emulator is enabled:
bodymust be a JSON-encoded string, not an object. As an object the RIE returnsjson: cannot unmarshal object into Go struct field APIGatewayV2HTTPRequest.body of type string.requestContext.http.methodset toPOST, otherwise Shimmy returnsinvalid method.Suggested fix
Document the standalone shape as the default, since it matches the
docker runcommand already on the page and is much simpler:Response:
{"command":"eval","result":{...}}.GET /healthalso works.Then, if the Lambda-emulator path is still worth documenting (for reproducing AWS behaviour), show it as a separate section with the two corrections:
{ "version": "2.0", "rawPath": "/", "requestContext": { "http": { "method": "POST", "path": "/" } }, "headers": { "command": "eval", "content-type": "application/json" }, "body": "{\"response\":\"a\",\"answer\":\"a\",\"params\":{}}", "isBase64Encoded": false }Both forms verified against a Python evaluation function built from the current boilerplate; the standalone form returns
200with the result, and the corrected envelope returnsstatusCode: 200with the result JSON-encoded inbody.