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
Good. Now let's add a
findRegionForApimethod toApiGatewayServiceand use it as fallback in the execute controller's dispatch method (for v1), plus check v2 service similarly.Assistant
Now let's do the same for ApiGatewayV2Service (getApi lookup for v2 HTTP APIs).
Assistant
Now let's update the
dispatchmethod inApiGatewayExecuteControllerto use these fallback lookups.Assistant
Now add the
resolveInvocationRegionhelper method just after the dispatch method (or before it).Assistant
Let's add a blank line before the dispatch method for readability, then compile the project.
Assistant
Duplicate line created (267-268). Let me fix.
Assistant
Good, fixed. Now let's compile the project.
Assistant
Compiles fine (with network access to Maven Central). Now let's run relevant tests.
Assistant
Test passed (no failures reported). Let's check the actual test result summary and also run full ApiGatewayExecuteControllerTest.
Assistant
Now let's write a temporary reproduction test to validate the actual bug scenario (creation with a non-default region header, then invocation with no Authorization header).
Assistant
The fix works. Let's verify it actually would have failed before the fix by reverting temporarily and re-running.
Assistant
Confirmed: reproduces the exact bug ("Invalid API id specified") without the fix, and passes with the fix. Now let's remove the temporary test file and run the broader apigateway test suite plus full test suite for regressions.
Assistant
Same exact failure counts (22 failures, 41 errors) before and after my changes — these are pre-existing environment/flakiness issues (likely networking/WebSocket related in this sandbox), not caused by my fix. Good, my change introduces no regressions.
Assistant
Let's view the full diff for final review.
Assistant
This confirms the same bug pattern for WebSocket connect. Let's fix it too, applying the same fallback strategy.
Assistant
Good — the region resolved once at connect time (line 103) is threaded through all subsequent calls. So fixing just the connect-time resolution fixes the whole WebSocket flow too.
Assistant
Now add the helper method
resolveRegionForApinearresolveRegionFromVertxRequest.Assistant
Good, that's fixed now. Let's compile the whole project to validate.
Assistant
Compiles cleanly. Now let's re-run the apigateway + apigatewayv2 test suites to confirm no new regressions from the WebSocket change.
Assistant
Same baseline number of failures (22 failures, 41 errors) as before my changes — no new regressions introduced. Let's also run the full existing user-request integration test to be thorough.
Assistant
All passing. Let's do a final review of the full diff.
Assistant
This diff looks clean and focused. Let's clean up temp files and do a final full test run limited to relevant packages plus a quick sanity compile.
Assistant
Good, no leftover temp test files. Let's run the full apigateway/apigatewayv2 tests one final time to confirm everything is stable.
Assistant
This matches the same baseline pre-existing failures (identical to the run before I touched
WebSocketHandler.java), confirming no regressions from any of my changes — these failures are environment-related (WebSocket handshake failures likely due to sandbox networking restrictions, and Lambda authorizer invocation environment issues unrelated to region resolution).Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.