Untitled conversation
- User
[BUG] API Gateway REST: path-based invocation (/restapis/{id}/{stage}/user_request/{path}) returns 404 After creating a REST API, adding a resource with a Lambda proxy integration, and deploying to a stage, invoking via the documented path format returns "Invalid API id specified" (404).
Reproduction
bash# Create Lambda function aws --endpoint-url=http://localhost:4566 lambda create-function \ --function-name test-fn --runtime nodejs22.x --handler index.handler \ --role arn:aws:iam::000000000000:role/r \ --code S3Bucket=...,S3Key=... # Create REST API + resource + integration + deployment API_ID=$(aws --endpoint-url=http://localhost:4566 apigateway create-rest-api --name test | jq -r '.id') ROOT_ID=$(aws --endpoint-url=http://localhost:4566 apigateway get-resources --rest-api-id $API_ID | jq -r '.items[0].id') RES_ID=$(aws --endpoint-url=http://localhost:4566 apigateway create-resource --rest-api-id $API_ID --parent-id $ROOT_ID --path-part hello | jq -r '.id') aws --endpoint-url=http://localhost:4566 apigateway put-method --rest-api-id $API_ID --resource-id $RES_ID --http-method GET --authorization-type NONE aws --endpoint-url=http://localhost:4566 apigateway put-integration --rest-api-id $API_ID --resource-id $RES_ID --http-method GET --type AWS_PROXY --integration-http-method POST --uri "arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:000000000000:function:test-fn/invocations" aws --endpoint-url=http://localhost:4566 apigateway create-deployment --rest-api-id $API_ID --stage-name dev # Invoke via documented path curl http://localhost:4566/restapis/$API_ID/dev/_user_request_/hello - Assistant
Now update
dispatch()in the execute controller: - Assistant
Now let me check the existing tests and run them:
- Assistant
Both suites pass. Let me verify the new test actually catches the bug — run it with the fix temporarily reverted:
- Assistant
Some authorizer tests fail — I need to check whether these are pre-existing failures (they invoke Lambda, which may need Docker) or caused by my change:
- Assistant
Several v2 WebSocket/authorizer suites also fail — let me confirm those are pre-existing too:
- Assistant
All failing suites fail identically on the pristine tree (same failure counts: 9, 5, 11 — they require Lambda execution via Docker, unavailable in this environment). The fix introduces no regressions.
Summary
Root cause: The
_user_request_andexecute-apidata-plane routes existed and matched correctly, butApiGatewayExecuteController.dispatch()resolved the region from the SigV4Authorizationheader. A plaincurlinvocation carries no auth header, so region resolution fell back to the default (us-east-1). Since APIs are stored under region-scoped keys (), the lookup missed and threw the 404 — exactly the reported behavior. Any API created via SigV4-signed management calls in a non-default region was un-invocable.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.