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. I'll search for API Gateway REST invocation and the "Invalid API id" error.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Let me look at the apigateway service more carefully for the user request / invocation path handling.
- Assistant
There's an
ApiGatewayUserRequestController— that should be the path-based invocation endpoint. - Assistant
The error may be a routing conflict with the management API. I'll check controllers and how "Invalid API id" is thrown.
- Assistant
I'll inspect request routing and how the RestEasy paths are registered.
- Assistant
Let me look at how AWS services are routed - specifically the core routing mechanism.
- Assistant
apigateway has hostnames "apigateway" and "execute-api". Let me understand on path-based routing when using localhost:4566.
- Assistant
Let me look at tests related to UserRequest and Execute, as well as the dispatch method and ApiGatewayController's getRestApi that might intercept the path.
- Assistant
There's already an ApiGatewayUserRequestIntegrationTest. Let me open it, and also check create-deployment / stage flow and how execution resolves APIs.
- Assistant
Region mismatch is a strong lead — AWS CLI uses eu-west-2 while bare curl may default elsewhere. I'll check RegionResolver and the rest of the user-request test.
- Assistant
The reproduction creates a stage only via
create-deployment --stage-name; I'll check whether that auto-creates the stage. - Assistant
"Invalid API id" means getRestApi ran — so something matches that path. Checking filters and routing that could rewrite the request.
- Assistant
I'll check recent git history and path-matching/resource conflicts that could explain the 404.
- Assistant
There's a commit "feat(parity): LocalStack drop-in compatibility (#696)" related to this. Let me also look at IamEnforcementFilter - maybe IAM rejects and returns Invalid API id?
- Assistant
Region mismatch looks likely: signed management calls use eu-west-2, bare curl uses default us-east-1. Checking whether execution looks up APIs across regions.
- Assistant
I'll check error response formats and run the user-request integration test.
- Assistant
Let me check AwsErrorResponse format vs jsonMessage:
- Assistant
Let me find jsonMessage method definition.
- Assistant
Error format confirms dispatch is hit and getRestApi fails — likely region mismatch. Checking how Lambda and API GW resolve resources across regions.
- Assistant
I'll implement cross-region API ID lookup for the data plane, and make create-deployment honor stageName. First I'll re-read createDeployment and related service patterns.
- Assistant
I'll check StorageBackend and whether v2 has a similar cross-region lookup pattern.
- Assistant
Account-aware storage may prefix keys with the account — I'll verify that next.
- Assistant
Account handling may differ between signed and unsigned requests — checking AccountContextFilter.
- Assistant
Checking documented invoke paths and any known gaps.
- Assistant
Let me read the API gateway docs for the exact workflow.
- Assistant
Checking v2 createDeployment and dispatch for the same issues.
- Assistant
Look at v2 createDeployment - it requires stage to already exist when stageName is provided. Let me read full v2 createDeployment:
- Assistant
I'll inspect the recent apigateway 404 fix — it may be related.
- Assistant
Let me try to run a focused unit-level test for—or better—reproduce with a simple quarkus test. First let...me check if Java is available and try compiling and running the tests quickly.
- Assistant
Implementing both fixes: resolve API ID across regions on the execute pathx and auto-create stages from create-deployment.
- Assistant
I'll apply the createDeployment stage fix and add cross-region API lookup for the data-plane dispatch.
- Assistant
I'll open the file at the right location and apply the edit.
- Assistant
Now I can use the replace command since the file is open and visible.
- Assistant
Next I'll add the async API region lookup helper beside getRestApi.
- Assistant
Let me go to getRestApi
- Assistant
I'll add findRegionForRestApi after getRestApi.
- Assistant
Adding the same helper on V2 and updating dispatch to use cross-region resolution.
- Assistant
Add findRegionForApi after getApi in V2.
- Assistant
Updating ExecuteController.dispatch to resolve the region from the API id.
- Assistant
I'll replace the region resolution portion of dispatch.
- Assistant
Simplifying the null-region branch and double-checking compilation imports.
- Assistant
Removing the unused initial region assignment.
- Assistant
Checking ExecuteController tests and whether regionResolver is still needed.
- Assistant
Running the API Gateway user-request and related integration tests.
- Assistant
HOME isn't set; I'll export it and re-run the tests.
- Assistant
UserRequest tests passed. The IntegrationTest failure was from an isolated ordered method. I'll run the full suite and a temporary cross-region/stageName check.
- Assistant
All tests passed. Cleaning up the temporary test and polishing the comment.
- Assistant
Checking whether Lambda invoke uses the API region or the region from the integration URI.
- Assistant
Checking Lambda region enforcement against the integration ARN.
- Assistant
functionNameFromUri - does it return full arn or just name?
- Assistant
extractFunctionNameFromUri - likely returns function name only not full ARN.
- Assistant
Temp test removed. Verifying the git status is clean aside from our intentional changes, 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.