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 mismatch with the narrowest available test before editing. After the fix, I’ll run focused and broader relevant tests and inspect the final diff.
- Assistant
The expected controller and an integration test already exist, so this is likely a subtle parameter-binding or dispatch issue rather than a missing endpoint. I’ll inspect the controller, invocation service lookup, test setup, and recent repository state to identify why the captured API ID differs from the stored ID.
- Assistant
The existing test uses direct REST calls without AWS SigV4, while the reported CLI-created API is region-scoped (
eu-west-2). The invocation endpoint likely derives a different region because curl is unsigned, causing the lookup to use the default region. I’ll inspect execute-controller region resolution and management controller request context, then run the existing test to establish baseline behavior. - Assistant
The baseline command exposed an environment issue (
HOMEis unset for Maven), but the code confirms the root cause: unsigned curl resolves to the configured default region, whereas AWS CLI stored the API undereu-west-2. Since this LocalStack-compatible path contains no region, execution must resolve the API’s owning region by its globally unique API ID when authorization does not supply one. I’ll inspect store APIs and region parsing conventions, then rerun the baseline withHOME=/root. - Assistant
The existing test passes only because setup and invocation both fall back to
us-east-1, so it does not cover the report. I’ll now reproduce accurately against a running instance: send management-plane requests with a synthetic SigV4 credential scope foreu-west-2, then invoke the documented URL unsigned. This isolates region resolution without requiring a real Lambda because a MOCK integration is sufficient to reach the same failing API lookup. - Assistant
The first live reproduction attempt did not start because Quarkus dev mode tried to read the detached shell’s input, and Python is unavailable. I’ll restart it with stdin redirected and use the installed JSON tooling (or simple
sed) to extract IDs, then repeat the same region-scoped setup. - Assistant
The service is now running. I’ll complete the setup using a shell JSON-field extractor and capture both the signed management lookup (to prove creation in
eu-west-2) and the unsigned data-plane response. - Assistant
The reproduction exactly matches the issue. I’ll implement a narrow fallback: preserve the authorization-derived region whenever the API exists there; for an unsigned execution request whose API is absent from the default region, locate a uniquely matching REST API ID across stored regions. If duplicate custom IDs make the path ambiguous, it will retain existing 404 behavior rather than route nondeterministically. Signed requests will continue honoring their credential scope.
- Assistant
I’ll add the unique-region lookup beside REST API retrieval and call it only during unsigned execution dispatch. The change is deliberately in shared execution dispatch so both documented
_user_request_and standard local execute paths behave consistently. - Assistant
The service edit is structurally correct. I’ll now update dispatch to detect an absent Authorization header, verify whether the REST API exists in the default region, and only then use the unique-region fallback. This avoids an unnecessary global scan for the normal/default case.
- Assistant
Compilation succeeds. I notice a minor formatting regression (missing blank line between methods), which I’ll clean up. Before restarting anything, Quarkus live reload should apply the code while retaining the reproduction API; I’ll invoke the exact failing URL again to verify the response now reaches integration handling rather than API lookup.
- Assistant
Quarkus live reload restarted the application and, with the in-memory backend, correctly wiped the previously created API; therefore that 404 is not a valid post-fix check. I’ll recreate the same
eu-west-2API after reload and immediately invoke it unsigned. - Assistant
The exact cross-region reproduction now returns HTTP 200, confirming routing reaches the configured integration. Next I’ll stop the dev process, run the focused
_user_request_integration test plus all API Gateway tests, and inspect failures. - Assistant
The 246-test run exercised the focused test successfully but 11 Lambda-backed tests failed solely because this environment has no Docker socket; the logs show container launch
No such file or directory, not routing regressions. While reviewing edge cases, I identified that checking for any Authorization header is too restrictive: a foreign-region API may legitimately receive a Bearer token for a custom authorizer. Since API ID identifies the data-plane target and signatures are not validated here, I’ll make fallback independent of authorization while still preferring the resolver’s region first. I’ll also inspect storage capabilities to avoid delimiter-based false matches for custom IDs. - Assistant
StorageBackendexposes keys and values separately, so I’ll retain region extraction from the matched key but additionally verify the storedRestApi.idexactly equals the requested ID. This prevents a custom ID such asprefix::idfrom falsely matching a request forid. Then I’ll simplify dispatch to always fall back only after the initially resolved region misses. - Assistant
Focused tests pass with the final logic. The broader API Gateway run had 246 tests total: 235 passed and 11 Docker-dependent Lambda authorizer tests failed because
/var/run/docker.sockis unavailable; the_user_request_, controller, proxy matching, and template tests all passed. I’ll perform final hygiene checks (diff, status, no lingering server, no test modifications) before submission. - Assistant
The final diff is limited to two production files and passes whitespace checks; no tests were changed. For strongest verification after the authorization-edge-case refinement, I’ll run one final live cross-region MOCK setup and assert the unsigned documented path returns 200, then stop the process and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.