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 usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /floci, current file: none) bash-$
- Assistant
I’ll first map the repository and locate API Gateway data-plane routing, then reproduce the route-matching failure with the narrowest available tests or a temporary request script. After identifying the mismatch, I’ll patch the implementation, exercise edge cases around path parsing, and run the relevant existing test suite.
- Assistant
The repository already contains a dedicated controller and integration test for this URL shape, so the likely defect is subtler than a missing endpoint—possibly parameter injection or repository lookup semantics. I’ll inspect the controller, service lookup, model/repository keys, and test configuration to trace the API ID from HTTP path to storage.
- Assistant
The path parameters are forwarded correctly in source, but the 404 specifically comes from the region-qualified
getRestApilookup. I’ll now inspect dispatch and region resolution, compare it with management controllers, and run the existing integration test to confirm the current branch reproduces the issue rather than relying on static inference. - Assistant
The reproduction’s key distinction from the existing test is now clear: AWS CLI signs management calls for
eu-west-2, while plaincurlhas no Authorization header.RegionResolvertherefore defaults the invocation tous-east-1, and storage is keyed by region, producing exactly “Invalid API id specified.” Since this documented path contains no region, execution must infer the API’s stored region by its globally unique API ID (while preserving explicit signed-region behavior where appropriate). I’ll inspect resolver defaults and service store abstractions, then design a lookup helper shared by REST and HTTP APIs rather than hardcoding a region fallback. - Assistant
The baseline test passes only because setup and invocation both use the default region, confirming its coverage gap and reproducing the causal condition by inspection: unsigned invocation resolves differently from signed
eu-west-2setup. The robust behavior is: first honor the resolved/requested region (maintaining current v2-before-v1 precedence), and only if no API exists there, locate the API ID across region-qualified stores. This supports plain documented URLs and execute-api emulation without weakening management-plane regional isolation. I’ll add narrowly scoped region lookup methods to both service versions and centralize fallback selection in dispatch. Then I’ll validate with a temporary reproduction that sets up one region and invokes unsigned from another. - Assistant
I’ll implement exact key-suffix matching (
::{apiId}), not substring matching, and extract only the region prefix. Dispatch will retain the currently resolved region whenever either API version exists there; cross-region discovery occurs only after both local lookups fail. This avoids changing normal signed requests and handles IDs that are substrings of other IDs. - Assistant
The edit command failed because this minimal environment lacks Python; no source changes were made, and the unchanged project compile still passed. I’ll apply the same targeted modifications using the repository’s
edit/replaceutilities, then compile again. - Assistant
Only the imports were applied; the editor utility requires the target area to be open before multiline replacement. I’ll use exact line-number insertions based on the now-current files, taking care that earlier insertions shift later lines, and then inspect the resulting methods in context.
- Assistant
I have exact insertion/replacement ranges. I’ll insert both service helpers immediately after their existing regional getters, then replace the dispatch’s API detection block and add two small existence helpers.
- Assistant
The compile caught one leftover declaration from the old block because the line shift was two lines less than estimated. I’ll remove those two stale lines and restore standard blank-line formatting between methods, then recompile.
- Assistant
Compilation now passes. To directly reproduce and verify the reported cross-region behavior without adding/modifying tests, I’ll start the emulator temporarily, issue management-plane REST calls with a synthetic SigV4 Authorization scope for
eu-west-2, configure a MOCK integration and stage, then invoke the documented URL with no Authorization header. This isolates the same region mismatch as the issue while avoiding Lambda packaging complexity. - Assistant
Quarkus dev mode suspended because it expects an interactive terminal, as anticipated by the environment constraints. I’ll instead build the runnable fast-jar and launch it with
nohupand stdin redirected from/dev/null, then run the HTTP reproduction. - Assistant
The packaged emulator is running. I’ll now execute the regional setup and print each extracted identifier plus the final unsigned response/status, so the verification is auditable.
- Assistant
The unsigned invocation changed from the reported “Invalid API id specified” to “Stage not found,” proving cross-region API discovery works. The temporary setup exposed an unrelated emulator behavior: deployment creation with
stageNamedid not auto-create the stage (the existing integration test creates it explicitly). To verify complete routing rather than stopping at API lookup, I’ll rerun the setup with an explicit stage creation, matching the project’s tested management sequence. - Assistant
The end-to-end temporary reproduction now succeeds: resources stored under
eu-west-2are invoked through an unsigned path (which defaults tous-east-1) with HTTP 200 and the MOCK response. I’ll run all API Gateway v1/v2 tests, then inspect the final diff for accidental scope or style issues and ensure no temporary repository files remain. - Assistant
The broad suite ran 649 tests but failed in 63 Lambda/WebSocket tests because this environment has no Docker socket (
java.net.SocketException: No such file or directory); these failures are infrastructure-related and unrelated to the patch. I’ll run the affected path’s MOCK integration test plus controller/resource-matching unit tests, all of which avoid external containers. I’ll also review final status/diff and clean generated untracked artifacts if any. - Assistant
The focused tests pass, and the final diff is limited to the three intended source files. I noticed two style-only missing blank lines from the editor’s insertion behavior and the original “Verify API and stage exist” comment was dropped during replacement; I’ll restore those before a final compile/status check.
- Assistant
The final compile passes and no emulator process remains. The editor normalizes trailing blank replacement text, so I’ll use
sedto add the two conventional method separators, then perform one last diff/status check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →