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 the path-based invocation handling related to this 404 bug.
- Assistant
This is a Java/Maven project. I'll search for API Gateway REST path handling and the "Invalid API id" error.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Found the user-request controller. I'll inspect it and how API IDs are resolved.
- Assistant
The 404 comes from
getRestApi; next I'll check how the execute path resolves region and API id. - Assistant
Path conflicts between management and user-request routes are a likely cause — I'll inspect the controller and related filters.
- Assistant
Region mismatch looks plausible — CLI creates the API in eu-west-2 while curl may look it up under the default region. Checking RegionResolver and lookup behavior.
- Assistant
I'll read the user-request integration test and how HTTP service routing is wired.
- Assistant
I'll check stage creation on deployment and whether API lookup is region-scoped.
- Assistant
Let me look at createDeployment more carefully - specifically if stageName is handled:
- Assistant
createDeployment ignores stageName — I'll confirm the stage-not-found error and how the controller handles create-deployment.
- Assistant
I'll check the edge/gateway routing that maps paths like
/restapisto services. - Assistant
There's also
src/main/java/io/github/hectorvent/floci/services/lambda/ApiGatewayController.java- that might be confusing! Let me also check for filters related to path routing. - Assistant
I'll inspect the execute controllers and the custom-domain filter next.
- Assistant
S3 path-style routes often steal unmatched paths — I'll check that next.
- Assistant
I'll look for cross-region API lookup and default-region docs next.
- Assistant
I'll run the user-request integration test to see if it fails in this environment.
- Assistant
HOME not set. Let me set it.
- Assistant
I'll inspect ServiceEnabledFilter and IAM enforcement for how they treat execute-api vs restapis paths.
- Assistant
API IDs may be unique while lookup is still region-scoped — I'll verify how IDs are generated and how execute resolves them.
- Assistant
I'll search docs and recent related changes, then reproduce with a non-default region.
- Assistant
I'll craft a focused test that creates the API in eu-west-2 and invokes it without auth, matching the bug report.
- Assistant
I'll review the API Gateway docs example and AWS create-deployment stageName handling.
- Assistant
I'll search for host-based execute-api routing and any path rewrite that could drop segments.
- Assistant
I'll inspect how create-deployment is handled and whether path matching could treat the stage as the API id.
- Assistant
The 404 shape matches execute-plane dispatch. I'll check v2 createDeployment stage handling and whether cross-region lookup already exists.
- Assistant
I'll inspect createStage and the Stage model, then apply the createDeployment + region lookup fixes.
- Assistant
I'll confirm the full dispatch flow, then implement createDeployment stage creation and cross-region execute lookup.
- Assistant
Implementing createDeployment stage association and cross-region API resolution for the execute path.
- Assistant
I'll apply the service changes now.
- Assistant
I'll use Éd replace for the changes.
- Assistant
Now replace createDeployment and add resolveRestApiRegion method.
- Assistant
Need to navigate to the right line first.
- Assistant
Now I can replace.
- Assistant
Next I'll add v2 region resolution and update the execute controller.
- Assistant
Need to add Optional import and resolveApiRegion method.
- Assistant
Need to goto line 14 first
- Assistant
Now replace imports and add method after getApi
- Assistant
Now add resolveApiRegion after getApi
- Assistant
Need to navigate to line 116
- Assistant
Now replace
- Assistant
Updating the execute controller's dispatch method next.
- Assistant
I'll update the dispatch method to resolve region via API id.
- Assistant
I'll add
@Blockingon the user-request controller and write a temporary reproduction test. - Assistant
Let me add @Blocking to UserRequest and AwsExecute controllers for consistency.
- Assistant
I'll create a temp test for the issue scenario and check AwsExecuteController for @Blocking next.
- Assistant
Tests passed. Removing the temporary repro test and running a broader API Gateway suite.
- Assistant
I'll verify account-aware storage key format doesn't break region resolution.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.