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
# 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_/helloActual behavior
HTTP 404:
{"message":"Invalid API id specified"}Expected behavior
Request routes through API Gateway to the Lambda function and returns the Lambda response.
Notes
- The API is created successfully (confirmed via get-rest-api and Floci logs)
- The deployment succeeds
- Management plane operations (create/get/update APIs) all work correctly
- Only the data plane invocation path fails
- Tested with Floci 1.5.16
Environment
- Floci 1.5.16 (docker.io/floci/floci:latest)
- Podman 5.8.0 rootless (also likely reproducible with Docker)
- AWS CLI v2
- Region: eu-west-2
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /floci, current file: none) bash-$
Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
.Let me explore the src directory structure more:
Assistant
Now let me look at the
ApiGatewayUserRequestControllersince the issue is about the data plane invocation path:Assistant
Now let me look at the
ApiGatewayExecuteControllerto see thedispatchmethod:Assistant
Now let me look for the "Invalid API" message in the codebase:
Assistant
Let me look at the v2 getApi method:
Assistant
Let me look at the key structure to understand if region matters:
Assistant
Let me look at the dispatch method more carefully and the resolveRegion method:
Assistant
Let me check the storage backend:
Assistant
Let me look at the CustomDomainFilter:
Assistant
Let me check the existing tests for the user request controller:
Assistant
Now let me look at the proxy match test to understand more:
Assistant
Let me look at the execute controller for context:
Assistant
Let me look at the dispatch method in detail to see how the v1 vs v2 check works:
Assistant
Let me check how to build and run the project:
Assistant
Let me first try to compile and run the existing test:
Assistant
Let me investigate more - the test passes. Let me try the issue with different regions:
Assistant
Now let me try running the test with a different region:
Assistant
Let me look at the
resolveRegionmethod more carefully and see if the issue is region-related:Assistant
Let me look at the actual implementation more carefully. Let me also check the application.yml:
Assistant
Let me start the dev server and try to reproduce the issue:
Assistant
Let me try without offline mode:
Assistant
It's still downloading. Let me wait longer:
Assistant
The dev mode is stuck waiting for input. Let me kill it and run a different approach - I'll build the project as a JAR and run it as a server:
Assistant
Server is up. Now let me reproduce the issue:
Assistant
Let me install jq:
Assistant
Now let me reproduce the issue:
Assistant
I reproduced the issue. The issue is that the API was created in
eu-west-2region (from the Authorization header), but the curl request has no Authorization header, so the default regionus-east-1is used.Let me confirm this is the issue:
Assistant
The issue is confirmed! When the request has no Authorization header, the default region is used (us-east-1) and the API is not found because the API was created in
eu-west-2region. Let me investigate how the system should handle this:Assistant
Let me see how the existing logic finds APIs:
Assistant
Let me check what
apiStore.scandoes and see all places where APIs are looked up:Assistant
Let me look at how the API store can be queried across all regions:
Assistant
Now let me look at the full dispatch method and understand what needs to change:
Assistant
Now let me think about the best approach. The cleanest fix is to add a method to look up the API across all regions:
Assistant
Let me look at the v2 service too:
Assistant
Let me look at how the issue was reported again. The user is using
curlwithout any auth header. The default region isus-east-1but the API is ineu-west-2. Let me check what existing fallback mechanisms might exist:Assistant
Now let me design the fix. I'll add a method to find the API across all regions and use it as a fallback:
Assistant
Now let me add a method to find the API across all regions:
Assistant
Now let me look at the existing
findApipattern or similar:Assistant
Now let me add a method to find API by ID across all regions:
Assistant
Now let me add a method to find the API across all regions:
Assistant
Let me try a different approach - using sed or using the proper format:
Assistant
Now let me add a similar method to the v2 service:
Assistant
Now let me modify the dispatch method to use these new methods:
Assistant
Now let me refactor the dispatch method:
Assistant
Let me revert and start over with a cleaner approach:
Assistant
Now let me write a cleaner patch:
Assistant
Let me check the rest of the dispatchV1:
Assistant
Now let me verify the RestApi class has a getRegion method:
Assistant
Let me check the v1 getRegion usage in my code and fix:
Assistant
Good, my code doesn't use api.getRegion() in v1 since I scan the keys. Let me verify my v1 service code once more:
Assistant
Let me check the v2 Api model:
Assistant
Good. Now let me build the project:
Assistant
Wait, "Nothing to compile" - that means my changes are not being picked up. Let me check:
Assistant
Actually, the compile was successful and the class file is newer than the source. Let me try to compile from scratch:
Assistant
Build succeeded. Now let me run the existing test to make sure it still passes:
Assistant
Now let me kill the running server and restart with the new code:
Assistant
Now let me test the fix:
Assistant
The fix works. Now let me test edge cases:
Assistant
Let me test more edge cases:
Assistant
Let me also test the v2 (HTTP API) case:
Assistant
Let me check why v2 API creation returned null:
Assistant
Let me check the v2 service to understand the integration creation:
Assistant
Wait, my command actually works! Let me look at the actual response. The integration was probably created, but the response was missing. Let me check what was actually returned:
Actually I see now - my command
INT_ID=$(curl -s -X POST ... | jq -r '.IntegrationId')- if the response is "1a6eaef2c8" or whatever, the integration was created. But it showsINT_ID: null. That means the response was empty. Let me check more carefully:Assistant
The integration IS created. The issue is the
INT_IDvariable wasnullbecause there was a typo or something. The response is{"integrationId":"8db7fbbd",...}and we need to use.integrationIdnot.IntegrationId. Let me retry:Assistant
The v2 routeKey is null. Let me check the route creation:
Assistant
The
RouteKeyfield name in the request body might be incorrect. Let me check:Assistant
The field is
routeKey(camelCase) notRouteKey. Let me re-test:Assistant
Let me check the target field name:
Assistant
Let me set the target via update:
Assistant
Now the v2 case works. Let me also test the v2 case with no auth header:
Assistant
Now let me also run all the API Gateway tests to make sure I didn't break anything:
Assistant
Let me check if these failures are pre-existing by stashing my changes:
Assistant
The 11 test failures are pre-existing. Let me restore my changes:
Assistant
Let me run the specific test for the user request path:
Assistant
Now let me also run a few related tests:
Assistant
Let me also run the v2 tests:
Assistant
Let me also look at the dispatchV2 to make sure my changes don't break anything:
Assistant
Let me also look at the full dispatchV1 to make sure I didn't introduce any issues:
Assistant
Let me check if the storage backend is thread-safe:
Assistant
Now let me also check if there are any other tests that might be affected:
Assistant
Let me look at the final diff:
Assistant
Let me run the build one more time to make sure everything compiles:
Assistant
Let me also do a comprehensive test by running a script:
Assistant
All tests pass. Let me also clean up the test file:
Assistant
Let me also re-run the full set of API Gateway tests:
Assistant
Same 11 pre-existing failures, none caused by my changes. Let me verify by checking which tests fail:
Assistant
Let me check the failing tests to confirm they're not related to my changes:
Assistant
The failing tests require Docker (for Lambda functions), which isn't available in this test environment. These are pre-existing failures.
Let me also check that the original issue (creating an API with eu-west-2 and invoking with curl) now works:
Assistant
The bug is fixed. Let me clean up and do a final check:
Assistant
Let me also confirm that my fix handles all the checklist items:
Checklist:
-
[x] If an error was reported in the issue description, I have successfully reproduced it.
- I reproduced the issue by setting up an API in
eu-west-2region and invoking it withcurl(no auth header). The default region isus-east-1, so the API was not found and returned "Invalid API id specified".
- I reproduced the issue by setting up an API in
-
[x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- After applying the fix, the same scenario returns
200 OKinstead of 404. I also tested via both/execute-api/{id}/{stage}/{path}and/restapis/{id}/{stage}/_user_request_/{path}paths.
- After applying the fix, the same scenario returns
-
[x] I have thought about edge cases and made sure my fix handles them as well.
- Edge cases tested:
- Non-existent API ID → 404 (Invalid API id specified) ✓
- Non-existent stage → 404 (Not Found) ✓
- Non-existent path → 404 (Not Found) ✓
- Wrong method (POST on a GET-only resource) → 405 (Method Not Allowed) ✓
- API in same region as request → 200 (no change in behavior) ✓
- API in different region from request → 200 (cross-region fallback) ✓
- v2 (HTTP API) case also fixed ✓
- Same region (us-east-1) still works ✓
- Wrong region auth header (us-east-1 for eu-west-2 API) → 200 (cross-region fallback) ✓
- Edge cases tested:
-
[x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
ApiGatewayUserRequestIntegrationTestpasses (6/6)ApiGatewayIntegrationTest,ApiGatewayProxyMatchTest,ApiGatewayExecuteControllerTestpass (56/56)- All 218 v2 tests pass
- The 11 failing tests in the full API Gateway test suite are pre-existing failures (require Docker for Lambda containers, not available in this test environment). I verified by stashing my changes and re-running the tests - the same 11 tests fail.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →