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 first map the repository and locate API Gateway data-plane routing, then reproduce the route-selection failure with the narrowest available test before changing it. After the fix, I’ll run focused and broader relevant tests and inspect the final diff.
- Assistant
This is a Maven/Java project with compatibility tests. I’ll now search both source and tests for
_user_request_, “Invalid API id”, REST API route definitions, and invocation handlers to identify whether the path parameter extraction or route ordering is at fault. - Assistant
A dedicated controller and integration test already exist, so the regression is likely subtle: framework parameter binding, controller registration, or service region/account lookup. I’ll inspect these files, nearby controllers’ binding conventions, build/compiler settings, and recent repository state to pinpoint why the test does not reflect the reported deployment behavior.
- Assistant
The current branch already contains a plausible endpoint and passing-looking test, while the report targets 1.5.16. I need determine whether that endpoint was added after 1.5.16 and whether it is actually correct in the present tree. I’ll inspect its commit history and execute the focused integration test as the concrete reproduction against current code.
- Assistant
The endpoint dates to an older fix, so this is a regression rather than a wholly missing feature. The first test attempt was blocked before Maven started because the environment has no
HOME; I’ll rerun with a temporary home (without altering the repository), and compare the endpoint’s original commit with current code plus release/tag ancestry. - Assistant
The focused test passes on 1.5.19, confirming current JVM mode supports the documented route. However, the history shows the endpoint’s fix may not have been included in any release tag (the
git tag --containsoutput was empty), despite being reachable from HEAD. I’ll inspect graph topology and the 1.5.16 snapshot directly. I’ll also test edge cases absent from the existing test—root invocation and nested paths—because the route regex currently requires a slash after_user_request_and may explain a path-shape regression. - Assistant
There are no local release tags, but commit dates establish that the dedicated route predates 1.5.16. Since current JVM tests pass, the likely deployment-specific distinction is native-image behavior or region resolution: the reproduction creates resources in
eu-west-2, while invocation requests do not carry AWS SigV4 headers. I’ll inspectdispatchandRegionResolver, then compare how management calls and execute paths derive region. This directly targets why a valid ID could be looked up under the wrong storage key. - Assistant
The root cause is now clear and matches the exact reproduction: AWS CLI management requests are SigV4-signed for
eu-west-2, so the API is stored aseu-west-2::{id}. Plaincurlhas no Authorization header, sodispatchlooks upus-east-1::{id}and returns “Invalid API id specified.” The current test misses this because both management and invocation use the default region.I’ll create a temporary (non-submitted) focused test that creates an API with a synthetic
eu-west-2SigV4 header and invokes it unsigned, confirm the 404, then remove the test. Before implementing, I’ll inspect dispatch’s REST/v2 fallback and storage key helpers so region fallback remains unambiguous and works for both API types. - Assistant
The temporary test reproduced the reported failure exactly: API creation logged
eu-west-2, and unsigned_user_request_invocation returned the expected erroneous 404.I’ll implement API-ID-based region discovery in the service and use it only when the initially resolved region does not contain that REST API. This preserves the fast/current-region path, keeps all subsequent stage/resource/Lambda lookups in the API’s actual region, and avoids hardcoding
eu-west-2. I’ll use anOptionalresult and exact storage-key suffix matching; generated API IDs are globally identifying, while current-region lookup remains authoritative if custom IDs collide across regions. I’ll include v2 fallback symmetry because the same dispatch method serves both API versions. - Assistant
I’ll keep the change narrowly scoped to REST APIs: after the existing v2/current-region check, dispatch asks the REST service to locate the API ID across stored regions. Sorting matching keys makes behavior deterministic for the pathological case where a custom ID is duplicated across regions; an API in the request/default region still wins before fallback.
- Assistant
Python is unavailable in the environment, so no files were changed. I’ll apply the same two focused edits using the repository’s editor commands instead: add
Optionaland the lookup method toApiGatewayService, then add region fallback indispatch. - Assistant
The import is correct. I’ll insert the documented lookup after
getRestApi, then patch dispatch at the exact current line range and run formatting/diff checks. - Assistant
The lookup method is correct; I noticed one missing blank line before the next method and will fix it while inserting the dispatch fallback. Then I’ll compile and rerun the temporary reproduction with a stronger assertion: after creating only the API cross-region, the response should now be “Invalid stage identifier” rather than “Invalid API id,” proving region resolution succeeded before building the full integration scenario. Afterward I’ll run the existing end-to-end mock test.
- Assistant
The diff is clean. I’ll add a readability blank line, identify the exact missing-stage message, and execute the post-fix cross-region test plus the existing complete
_user_request_integration test. The temporary test will be deleted immediately afterward andgit statuschecked to ensure no test changes remain. - Assistant
The code behaved correctly; my temporary assertion used the wrong existing service message (
Stage not found). The response changed from “Invalid API id” to “Stage not found,” already proving the lookup fix, and the existing seven-step invocation scenario also completed successfully in the same run. To satisfy the issue exactly, I’ll now run one temporary single-test scenario where every management operation is signed foreu-west-2, while the final invocation is unsigned, and assert the mock integration’s 200 response. - Assistant
The exact cross-region end-to-end reproduction now passes with HTTP 200 and the expected mock response, and the temporary test has been removed. I’ll run the permanent API Gateway execution/user-request suites together, then perform a package compile/test selection and inspect the final diff/status. I’ll also consider whether current-region and unknown-ID behavior remain unchanged (both follow directly from the current-region-first lookup and
orElse(region), and the permanent tests exercise current-region behavior). - Assistant
Both permanent execution suites pass. The cross-region logic also preserves unknown IDs: no matching key returns the originally resolved region, producing the same 404. It preserves duplicate custom-ID semantics by preferring the explicitly resolved/default region, then choosing a deterministic stored region only when necessary.
I’ll run the controller unit suite and general API Gateway integration suite as a final regression check, then review the complete diff and whitespace/status before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.