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 locating the API Gateway REST invocation path handling.
- Assistant
This is a Java/Maven project. Let me find the API Gateway related code.
- Assistant
Let me search more specifically for apigateway related code.
- Assistant
rg is not available, let me use grep instead.
- Assistant
The UserRequest controller looks central — I'll read it and related routing next.
- Assistant
The 404 likely comes from path routing conflicts or API ID lookup — I'll inspect those next.
- Assistant
I'll compare the user-request integration test with path registration/routing next.
- Assistant
I'll check routing and region prefixing next, then finish reading the user-request test.
- Assistant
Region-keyed API lookup may be the issue — inspecting how APIs are stored and retrieved.
- Assistant
Region mismatch between signed management calls and unsigned invoke looks plausible — checking RegionResolver.
- Assistant
Let me read the RegionResolver fully and also look at how the path matching might cause conflict. Also check CHANGELOG and recent commits related to this bug.
- Assistant
Next I'll verify whether execute-api already does a cross-region API lookup.
- Assistant
I'll check AGENT.md and similar region-lookup patterns reused elsewhere.
- Assistant
Let me look more carefully. Perhaps the issue is a path routing conflict at the JAX-RS level.
- Assistant
I'll inspect Lambda's ApiGatewayController and any catch-all routes that could steal this path.
- Assistant
I'll inspect host-based execute-api routing and recent related fixes next.
- Assistant
Let me look at how create-deployment with stage-name works - maybe stage isn't created properly, but that would give a different error (Invalid stage identifier, not Invalid API id).
- Assistant
I'll check another angle: path matching may map
_user_request_onto an incorrect controller path. - Assistant
Account-aware storage may explain this — checking that path next.
- Assistant
I'll inspect AccountResolver and related tests, then draft a fix.
- Assistant
Let me look at how AWS CLI maps create-deployment with stage-name - maybe that's a separate AWS API that auto-creates stage. And let me try to run unit tests to reproduce.
- Assistant
I'll confirm both issues and implement region fallback plus stage creation on deployment.
- Assistant
Confirming root cause: unsigned data-plane calls resolve to the default region, so APIs created in another region aren't found. I'll also fix create-deployment to honor stageName.
- Assistant
Implementing region fallback for execute-api and wiring createDeployment to create/update stages when stageName is set.
- Assistant
Need to open the file around that line first, or use a different approach.
- Assistant
Now I can edit.
- Assistant
I'll clean up the Optional import and fix createDeployment next.
- Assistant
Need to open at the top of the file.
- Assistant
Let me edit center codes.
- Assistant
Now update findRegionForRestApi to use Optional without FQCN, and fix createDeployment.
- Assistant
Let me fix Optional references and createDeployment.
- Assistant
Now fix createDeployment.
- Assistant
Now update createDeployment.
- Assistant
Now update ApiGatewayV2Service with findRegionForApi and update ExecuteController.
- Assistant
I'll add Optional import and findRegionForApi after getApi.
- Assistant
Now add findRegionForApi method after getApi.
- Assistant
Add findRegionForApi after getApi.
- Assistant
Now update the dispatch method in ApiGatewayExecuteController.
- Assistant
I'll replace the region resolution section of dispatch.
- Assistant
I'll insert the resolveExecuteRegion helper right after dispatch.
- Assistant
Need to open around that line again.
- Assistant
Now try the replace again.
- Assistant
Simplifying resolveExecuteRegion — the previous version was inefficient.
- Assistant
I'll update the javadoc to match the simplified implementation.
- Assistant
I'll run the API Gateway tests to verify the changes.
- Assistant
HOME isn't set — I'll export it and retry.
- Assistant
Tests look green — next I'll check the exit code and add a temporary cross-region reproduction.
- Assistant
I'll add a temporary cross-region reproduction test, run it, then remove it.
- Assistant
Cross-region test passed. Removing the temporary test file next.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.