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 using command. Additionally, you can use and to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I'll start by exploring the repository structure and searching for code related to the REST API path-based invocation that's returning 404.
- Assistant
This is a Java/Maven project. Let me search for API Gateway and the specific error message.
- Assistant
Let me find the apigateway service specifically.
- Assistant
rg is not found - maybe I need to use grep. Let me explore the apigateway directory.
- Assistant
There's a
ApiGatewayUserRequestController— let me inspect that and how routing works. - Assistant
There's likely a path conflict between management and invoke routes. Let me inspect routing and related tests.
- Assistant
I'll inspect how requests are routed to API Gateway and where the API ID is looked up.
- Assistant
Let me check how
dispatchresolves region and looks up the API, and how RegionResolver works with curl requests. - Assistant
Let me look more carefully at the dispatch method - it first tries v2 getApi, then v1 getRestApi. Let me also check git history for related changes and if there's a known issue with path/matching.
- Assistant
Looking at createDeployment:
- Assistant
The error is specifically "Invalid API id specified", not a stage error. Let me dig into path matching, filters, and recent API Gateway commits.
- Assistant
Region mismatch between AWS CLI-created APIs and plain curl looks plausible — let me verify default region handling and multi-region lookups.
- Assistant
Let me check AWS create-deployment stageName handling and path-matching conflicts more carefully.
- Assistant
Account isolation between authenticated management calls and unauthenticated curl looks like a strong lead — I'll check that next.
- Assistant
I'll check StorageFactory for account isolation effects on unauthenticated invocation.
- Assistant
Let me check AccountResolver and how credentials map to accounts, and whether path matching might steal the route.
- Assistant
I'll check ServiceEnabledFilter and global routing for path collisions.
- Assistant
I'll run the existing user-request integration test to reproduce the failure.
- Assistant
I'll set HOME and rerun the test.
- Assistant
The existing test passes in us-east-1. I'll carefully reproduce the eu-west-2 + curl (no auth) scenario from the issue.
- Assistant
I'll write a temporary test matching the issue scenario: non-default region and
create-deployment --stage-name. - Assistant
Reproduced both issues: region default mismatch and
create-deploymentignoringstageName. Checking AWS/Floci patterns for data-plane lookup and deployment stage creation. - Assistant
I'll inspect Deployment and Stage models, then implement both fixes.
- Assistant
Looking at v2 createDeployment too.
- Assistant
Implementing both fixes: create-deployment creating the stage, and data-plane resolving APIs across regions.
- Assistant
I need to add Optional import if not already present.
- Assistant
I'll add Optional import and update createDeployment and add findRegionForRestApi.
- Assistant
Now update createDeployment and add findRegionForRestApi after getRestApi.
- Assistant
Now add findRegionForRestApi near getRestApi.
- Assistant
I'll insert after getRestApi.
- Assistant
I'll insert findRegionForRestApi after getRestApi.
- Assistant
Now add the same for V2 API and update ExecuteController.dispatch.
- Assistant
Let me update V2 service and execute controller.
- Assistant
Need to use open first or use a different path.
- Assistant
Continue with edits.
- Assistant
Now add findRegionForApi method after getApi.
- Assistant
I'll insert findRegionForApi after getApi.
- Assistant
Now update ExecuteController.dispatch to resolve region by API id.
- Assistant
I'll replace the dispatch method's region resolution logic.
- Assistant
Now I need to add the resolveExecuteRegion method. Let me find a good place - near dispatch or helper methods.
- Assistant
Updating the repro test to assert the fix, then running it.
- Assistant
All tests passed. Removing the temporary repro test and running a broader API Gateway suite.
- Assistant
Some authorizer tests failed — checking whether they were already flaky or my change caused them.
- Assistant
Those failures are pre-existing (likely Lambda/Docker). Restoring my changes.
- Assistant
Verifying the final diff, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.