ISSUE DESCRIPTION [BUG] API Gateway REST: path-based invocation…
- User
ISSUE DESCRIPTION
[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 let's create a temporary test file (will remove before submitting) to reproduce the issue with AWS_PROXY + user_request path.
Assistant
Both use same key pattern. Let's add helper methods to both services and update the dispatch logic accordingly.
Assistant
Now let's add a
findRegionForApimethod in both services.Assistant
Now let's add the
findRegionForApihelper method right aftergetRestApi.Assistant
Use the
replacespecial command instead.Assistant
Now let's add the equivalent method for ApiGatewayV2Service.
Assistant
Now let's update the
dispatchmethod in ApiGatewayExecuteController to use these lookups when the resolved region doesn't match.Assistant
Now add the
resolveExecutionRegionhelper method right afterdispatch.Assistant
All 5 tests passed (created API in eu-west-2, invoked without auth header and it succeeded). Let's confirm by checking surefire report.
Assistant
Now let's verify this actually reproduces the bug pre-fix by temporarily reverting the fix and re-running.
Assistant
Confirmed - this reproduces the exact bug (404 with unsigned/no-region requests) before the fix, and both fail without the fix. Now let's restore the fix.
Assistant
Now let's rerun with the fix applied to confirm, then run the full existing apigateway test suite to check for regressions.
Assistant
Fix confirmed working. Now let's run the full apigateway test suite (and apigatewayv2) to check for regressions.
Assistant
Good - same 11 failures occur on baseline too (docker unavailable in sandbox), confirming these are pre-existing environment failures unrelated to my change. Let's restore the fix.
Assistant
Both baseline and fixed versions have exactly the same 11 pre-existing failures (all due to lack of docker in this sandbox — 502/403 responses from Lambda-based authorizer tests that can't launch containers), confirming my change introduces no regressions. Let's also run the full test suite for a final sanity check on other modules that might reference these services (like CloudFormation or compatibility tests referencing apigateway).
Assistant
No other tests directly reference these methods. Let's check that the diff is clean.
Assistant
The diff is clean and focused. Let's also verify there's no leftover temp test file.
Assistant
Good — no leftover temp file (only pre-existing
VtlTemplateEngineTest.javamatched the grep coincidentally). Now let's run the existingApiGatewayUserRequestIntegrationTestandApiGatewayExecuteControllerTestonce more to be thorough.Assistant
All targeted tests pass. Let's also double check surefire summary counts.
Assistant
All pass. Let's review the checklist and finalize.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.