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
Let me start by understanding the issue. The problem is that REST API Gateway path-based invocation (using
/restapis/{id}/{stage}/_user_request_/{path}) returns 404 with "Invalid API id specified". This is a data plane invocation path that should route requests through API Gateway to the backend (Lambda in this case).Let me explore the repository structure first to understand the codebase.
Assistant
This is a Java project (Maven-based). Let me explore the source code to understand the structure.
Assistant
Let me look for API Gateway related code.
Assistant
Let me look at the key files related to the REST API invocation path.
Assistant
Let me do one command at a time.
Assistant
Now let me look at the
ApiGatewayExecuteControllerto understand the dispatch method.Assistant
Let me look at the
AwsServiceRouter.javawhich likely routes requests for different services.Assistant
Now let me look at the main
ApiGatewayController.javawhich handles the management plane for REST APIs.Assistant
Let me look at the test file for the user request integration to understand the expected behavior.
Assistant
Let me first run the specific test to see if
Assistant
The issue is that HOME is not set. Let me set it.
Assistant
The test seems to pass. Let me run with more verbose output to confirm.
Assistant
Let me look at the custom domain filter and other routing-related files.
Assistant
Let me search for all path annotations in ApiGatewayController.
Assistant
Let me see more of the paths.
Assistant
The test passes, so let me check if there's a specific integration test for AWS_PROXY with the
_user_request_path.Assistant
Let me look at the
ApiGatewayAwsExecuteController.javaand find the/_aws/execute-apihandlerAssistant
Let me search for "Invalid API id specified" to find where this error comes
Assistant
Let me look at how
getRestApiworks inApiGatewayService.java.Assistant
Let me look at the
getRestApimethod and the surrounding code inApiGatewayService.java.Assistant
Let me look at the
apiKeymethod and how the API store worksAssistant
Let me look at the
apiKeymethod definitionAssistant
Let me look at the apiKey method at line 1258:
Assistant
Let me check the git history to see if there were recent changes related to this issue.
Assistant
Let me run all the API Gateway tests to see if any fail.
Assistant
Let me try different test patterns.
Assistant
Let me look at the
ApiGatewayAwsIntegrationTestto see if it tests the_user_request_path with AWS integrationAssistant
Let me look at the RegionResolver to understand how region is resolved
Assistant
Let me look at the full dispatch method in
ApiGatewayExecuteController.javaAssistant
Let me check git history for changes related to the
_user_request_path or `ApiGatewayUserRequestControllerAssistant
Let me look at all the
@Pathannotations inApiGatewayControllerthat could conflict with the_user_request_pathAssistant
Let me look at the Quarkus configuration files for any relevant routing settings
Assistant
Let me look at the main application.yml and the test application.yml.
Assistant
Let me search for any method that might match
/restapis/{apiId}/{stageName}/_user_request_in the ApiGatewayControllerAssistant
Let me look at the methods at lines 553 and 571 of ApiGatewayController
Assistant
Let me look at the commit that introduced the
ApiGatewayUserRequestControllerAssistant
Let me see the full diff of that commit
Assistant
Let me check which tags include this commit
Assistant
Hmm, no output. Let me check the tags differently.
Assistant
Let me check the git log for version tags
Assistant
Let me check where the commit 55325ec is in the history
Assistant
Let me verify my theory about region mismatch. Let me look at how
createRestApiresolves the regionAssistant
Let me look at how the
getStagemethod resolves the regionAssistant
Let me write a quick script to reproduce the region mismatch
Assistant
Let me check if
ApiGatewayAwsExecuteControllerhas@ApplicationScopedAssistant
Let me look at the
ApiGatewayProxyMatchTestto understand how path matching worksAssistant
Let me start the application and test the exact scenario from the bug report
Assistant
Let me kill the background process and look at the
invokeProxymethod more carefully.Assistant
Let me look at the pom.xml for RESTEasy version and any relevant configuration
Assistant
Let me check the pom.xml for RESTEasy dependency
Assistant
Let me search for methods in ApiGatewayService that search across all regions
Assistant
Let me look at the ApiGatewayV2Service.getApi method to see how it handles region
Assistant
Let me look at the full
dispatchmethod to determine the best approachAssistant
Let me look at the StorageBackend interface for available methods
Assistant
Let me look at the StorageBackend interface
Assistant
Let me look at the RestApi model to see if it stores the region
Assistant
Now I have a good understanding of the issue. Let me implement the fix. The problem is that the data plane invocation resolves the region from the Authorization header (or defaults to
us-east-1), but the API might have been created with a different region. The fix should add a fallback mechanism to find the API across all regions.First, let me add a method to
ApiGatewayServiceto find a REST API by ID across all regions:Assistant
Let me add a method to find a REST API across all regions in
ApiGatewayService.java:Assistant
Let me add the fallback method to
ApiGatewayService.javaAssistant
I see the issue - the edit removed the
getRestApismethod signature. Let me fix this.Assistant
Let me fix the broken
getRestApismethodAssistant
Good. Now let me check if
Optionalis already imported inApiGatewayService.javaAssistant
Let me add the import for
OptionalinApiGatewayService.javaAssistant
Let me check the file header - the import was inserted before the package statement
Assistant
The package statement was removed! Let me fix it.
Assistant
Now let me modify the
dispatchmethod inApiGatewayExecuteController.javato use the fallback. Let me first look at the exact code to edit.Assistant
Now let me edit the
dispatchmethod to add the fallback region lookup:Assistant
There are leftover duplicate lines. Let me fix them.
Assistant
Now let me also add the same fallback for the v2 API check. Let me look at the v2 code and also add the fallback:
Assistant
Now let me run the existing tests to verify everything still works
Assistant
All 98 tests pass. Let me run all API Gateway related tests to make sure nothing is broken.
Assistant
Let me check the git status to see my changes
Assistant
Let me see the full diff
Assistant
Now let me write a quick test to verify the regional mismatch scenario is fixed. Let me first check if the tests that failed are pre-existing failures by running them before my changes.
Actually, the Docker socket errors are clearly pre-existing and unrelated to my changes. Let me now run the most relevant tests once more to confirm everything passes.
Assistant
Let me also add a consistent fallback for v2 APIs. First, let me add
findApiRegiontoApiGatewayV2ServiceAssistant
Let me look at the
getApimethod inApiGatewayV2Serviceand addfindApiRegionAssistant
Let me add a
findApiRegionmethod toApiGatewayV2Servicesimilar to the one I added toApiGatewayService.Assistant
Let me fix the missing blank line and check the import
Assistant
Let me check the imports in
ApiGatewayV2Service.javaand addOptionalif neededAssistant
Let me add the import for
OptionalinApiGatewayV2Service.javaAssistant
Now let me update the v2 fallback in
ApiGatewayExecuteControllerto usefindApiRegioninstead of just the default regionAssistant
Now let me run the tests again to verify everything still works
Assistant
All tests pass. Let me also run the v2 tests to make sure they work too
Assistant
Let me check the BUILD status only
Assistant
Let me see the full output to understand the error
Assistant
Let me just check the final build
Assistant
All tests pass. Let me review the final diff
Assistant
The changes are complete. Let me verify the final state of all changed files and run the tests one more time to be sure.
Assistant
Let me run the complete API Gateway test suite one final time
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.