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 exploring the repository structure to understand how it's organized and find the relevant code for API Gateway REST API handling.
Assistant
The issue is about API Gateway REST API path-based invocation failing. Let me look at the repository structure more closely, particularly for API Gateway related code.
Assistant
There are no files with "api" in their name. Let me look at the top-level directory structure and find the relevant code.
Assistant
This is a Java/Maven project. Let me explore the source code structure.
Assistant
Let me find the API Gateway related Java files specifically.
Assistant
Let me look at the key files for API Gateway REST API handling, especially the user request controller.
Assistant
Now let me look at the ApiGatewayExecuteController to understand how it dispatches requests.
Assistant
Let me look at the test file for the user request controller and the ApiGatewayService to understand the issue better.
Assistant
Let me look at the ApiGatewayController to understand how routing is set up:
Assistant
Let me look at the critical dispatch method more carefully:
Assistant
Let me see the dispatch method more carefully, starting from line 226.
Assistant
Let me look at the ApiGatewayService to understand the getRestApi and getStage methods:
Assistant
Let me look at how
getStageworks and the deployment creation:Assistant
Let me look at the deployment creation and how stages are set up with deployments:
Assistant
Let me look at the createDeployment method more closely and how it handles apiStages:
Assistant
Let me look at the createDeployment method in full to see if it handles apiStages:
Assistant
Now let me look at the createDeployment endpoint in the controller to see how it handles
stageName:Assistant
Let me look at the createDeployment endpoint in the controller.
Assistant
Assistant
(Thinking) Let me check the Stage model file to understand its structure.
Assistant
Now I understand the issue. The
createDeploymentmethod doesn't handle thestageNamefield. When a user callscreate-deployment --stage-name dev, the stage isn't created, so subsequent requests to/restapis/{apiId}/dev/_user_request_/...fail because the stage doesn't exist.Let me verify by looking at the exact method:
Assistant
Now I understand the issue. The
createDeploymentmethod doesn't handle thestageNameparameter. When a user callscreate-deployment --stage-name dev, the stage isn't created, so subsequent requests to/restapis/{apiId}/dev/_user_request_/...fail because the stage doesn't exist.Let me look at what fields
createDeploymentshould handle from the AWS CLI:Assistant
Now I understand the issue. The
createDeploymentmethod doesn't handle thestageNameparameter. Whencreate-deployment --stage-name devis called via AWS CLI, thestageNameis included in the request body, but the service ignores it. This means no stage is created, and subsequent invocation requests fail.Let me write a reproduction script first to confirm the issue:
Assistant
Let me run the existing test first to see how the system works:
Assistant
Let me try using a different approach to build and run tests.
Assistant
The test passes, but it creates the stage separately. Let me create a test script that reproduces the exact issue (creating a deployment with
--stage-nameinstead of creating a stage separately):Assistant
Let me run this test to confirm the issue.
Assistant
The test confirms the issue. The
verifyStageExiststest fails because the stage "dev" was not created when callingcreate-deploymentwithstageName: "dev". TheinvokeViaUserRequestPathtest also fails with 404.Now let me fix the
createDeploymentmethod inApiGatewayService.javato handle thestageNameparameter:Assistant
Now let me fix the
createDeploymentmethod to handle thestageNameparameter:Assistant
Now I need to edit the
createDeploymentmethod to handle thestageNameparameter. WhenstageNameis provided in the request, we should create or update the stage with this deployment.Looking at the
createStagemethod:- It requires
stageNameanddeploymentIdin the request - It creates a new Stage object
- It stores it in the stageStore
For the
createDeploymentmethod, I need to:- Create the deployment as before
- If
stageNameis provided in the request, create or update the stage with this deployment's ID
Let me edit the code.
- It requires
Assistant
Now I'll fix the
createDeploymentmethod to handle thestageNameparameter:Assistant
The edit was applied successfully. Let me verify the code looks correct by checking the modified section:
Assistant
Now let me run the test to verify the fix:
Assistant
The test passed! I can see:
- "Created deployment c011b40008 for API e669fbaafd"
- "Created stage dev for API e669fbaafd"
The fix is working. Now let me run the existing tests to make sure I didn't break anything:
Assistant
Existing test still passes. Let me run all API Gateway related tests to make sure I didn't break anything:
Assistant
Let me check if these test failures existed before my change by running them without my change. First, let me stash my changes:
Assistant
Let me run the failing tests without my change to see if they were already failing before.
Assistant
Good - these tests were already failing before my change. Let me restore my changes:
Assistant
Good - the failing tests were already failing before my change, so my change didn't break anything. Let me clean up and run the API Gateway integration tests specifically:
Assistant
Let me run the existing relevant API Gateway tests to confirm my change works:
Assistant
Let me run the test again to see the output more clearly.
Assistant
The test passed. Let me run more API Gateway tests to confirm everything works:
Assistant
Let me now verify that the existing tests still pass and confirm my fix handles edge cases. Let me run a few more relevant tests.
Assistant
Let me also run the proxy match test which was mentioned in the test file listing:
Assistant
Let me verify my fix and review the final state of the changes:
Assistant
Let me run more comprehensive tests to ensure my changes don't break anything:
Assistant
All 117 tests passed. Let me verify the fix is complete by checking the final diff:
Assistant
The fix is complete. Let me provide a summary:
Summary
Root Cause
The
createDeploymentmethod inApiGatewayServicedidn't handle thestageNameparameter. When users calledcreate-deployment --stage-name devvia AWS CLI, the stage wasn't created, causing subsequent requests to/restapis/{apiId}/dev/_user_request_/helloto fail because the stage didn't exist.Fix Applied
Modified the
createDeploymentmethod in/floci/src/main/java/io/github/hectorvent/floci/services/apigateway/ApiGatewayService.javato:- Check if
stageNameis provided in the deployment request - If so, create or update the stage with the new deployment's ID
- Also handle
stageDescriptionif provided in the request
Changes Made
- Added 13 lines of code to handle the
stageNameparameter increateDeployment
Testing
- All 117 related API Gateway tests pass
- The pre-existing authorizer test failures were already present before this change (verified by stashing and running tests)
- The
ApiGatewayUserRequestIntegrationTestconfirms the path format works correctly
- Check if
Assistant
The error indicates that I need to submit my changes since I've already completed the fix. Let me submit the changes.
Assistant
The fix is complete. Let me submit the changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.