Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [BUG] API Gateway REST: path-based invocation…

  1. 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_/hello
    

    Actual 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 git reset --hard command. Additionally, you can use git stash and git stash pop 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 submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    Let me explore the repository structure to understand what we're working with.

  3. GLM Assistant

    This is a Java project (Maven). Let me explore the source structure and find the API Gateway related code.

  4. GLM Assistant

    Let me look at the routing. There's likely a conflict because the management plane ApiGatewayController also uses /restapis path. Let me check.

  5. GLM Assistant

    The management plane controller has paths like /restapis/{apiId} etc. The user request controller has /restapis/{apiId}/{stageName}/_user_request_.

    The issue is "Invalid API id specified" 404. Let me look at the ApiGatewayController for the @Path("/restapis/{apiId}") GET to see where "Invalid API id specified" comes from.

  6. GLM Assistant

    Now let me look at the ApiGatewayExecuteController to understand the dispatch method and how the apiId is being resolved. The issue says invoking via /restapis/$API_ID/dev/_user_request_/hello returns 404 "Invalid API id specified".

    The user request controller calls executeController.dispatch("GET", apiId, stageName, proxy, ...). Let me look at the dispatch method.

  7. GLM Assistant

    The "Invalid API id specified" comes from getRestApi, called by dispatch. So dispatch IS being reached but getRestApi(region, apiId) fails. Let me look at RegionResolver to understand region resolution.

  8. GLM Assistant

    So resolveRegion resolves the region from the Authorization header (Credential=AKID/date/region/...). When you use curl directly, there's no Authorization header, so it returns the default region.

    If the API was created in eu-west-2 but the default region is us-east-1, then the getRestApi would fail with "Invalid API id specified".

    But wait, the issue says this is reproducible. Let me think about whether this is the actual root cause. The issue title says path-based invocation returns 404. Let me actually try to reproduce. But first, let me understand how the management plane resolves region.

    Actually, the AWS CLI sends the Authorization header with the region. So management plane operations use the correct region eu-west-2. But curl without auth uses the default region.

    However, this is a behavior issue. In LocalStack, the API Gateway invocation works regardless of region because LocalStack uses a single global store or resolves region from the API id. Actually, the API id is globally unique in LocalStack.

    Hmm. But let me think about the actual issue. The issue is path-based invocation. Let me check whether the routing actually reaches the UserRequestController.

    Actually, let me first reproduce the issue by building and running. Let me check the test directory for existing tests around this.

  9. GLM Assistant

    This test uses the default region (no Authorization header), so both create and execute use the default region and it works. The issue arises when the API is created in a non-default region (eu-west-2) via AWS CLI (which sends the Authorization header with the region), but the curl invocation has no auth header, so it resolves to the default region. Let me verify by looking at the dispatch logic more and the v1 store keys.

  10. GLM Assistant

    Confirmed. The API is region-scoped. The data plane invocation with curl (no auth) resolves to the default region, so it doesn't find the API created in eu-west-2. Let me check the default region config.

  11. GLM Assistant

    Default region is us-east-1. So an API created in eu-west-2 and invoked via curl (no auth) resolves to us-east-1 → not found → 404. Let me check the StorageBackend interface to see what scan/lookup methods are available.

  12. GLM Assistant

    There's scan(Predicate<K>) returning values and keys() returning keys. Let me check the v2 service getApi and how the execute-api dispatch uses the region downstream, plus how dispatchV2 resolves region.

  13. GLM Assistant

    Now let me look at the full dispatch method and the dispatchV2 to understand how region is used downstream, so I can design the fix consistently.

  14. GLM Assistant

    Let me check the RestApi model to see if it stores the region.

  15. GLM Assistant

    Now I understand the root cause. The data plane dispatch resolves the region from the Authorization header. A curl request without auth resolves to the default region (us-east-1), but the API was created in eu-west-2 (via AWS CLI which sends the region in the auth header). Since API ids are unique across the emulator, the fix is to fall back to a global lookup by apiId when the API isn't found in the resolved region.

    Let me check the v2 service's apiKey helper and store field name.

  16. GLM Assistant

    Let me look at how tests set the region (e.g. via Authorization header) so I can write a reproduction.

  17. GLM Assistant

    Those Authorization headers are for the authorizer (Bearer tokens), not for AWS SigV4 region. Let me check how the region is determined in the management plane. Let me look at how the CLI sends region. Actually, let me look at how the management controller resolves region - it uses a similar regionResolver.

    Let me look at how a test creates an API in a specific region. Let me search for tests that set a region header.

  18. GLM Assistant

    Let me look at how the management controller resolves region for create operations.

  19. GLM Assistant

    So the management plane resolves the region from the Authorization header (Credential region). The AWS CLI sends the region, so the API is stored in eu-west-2. A curl without auth resolves to the default us-east-1, hence the 404.

    Let me look at dispatchV2 to understand if it re-resolves region internally.

  20. GLM Assistant

    dispatchV2 uses the region passed in. So fixing region resolution before calling it is sufficient. Now let me implement the fix. First, add a helper method to ApiGatewayService.

  21. GLM Assistant

    Now let me add the helper method to ApiGatewayService:

  22. GLM Assistant

    Now let me add the analogous helper to ApiGatewayV2Service:

  23. GLM Assistant

    Now let me modify the dispatch method in ApiGatewayExecuteController to use the global fallback:

  24. GLM Assistant

    Now let me rewrite the dispatch method's region resolution to add the global fallback:

  25. GLM Assistant

    Now let me build to verify compilation and run the existing related tests.

  26. GLM Assistant

    Compilation succeeded. Now let me create a temporary reproduction test (I'll remove it before submitting) that creates an API in a non-default region via an Authorization header and invokes via _user_request_ without auth.

  27. GLM Assistant

    Now let me run the temporary test plus the existing user request test to confirm the fix works and nothing breaks.

  28. GLM Assistant

    Offline mode is missing the surefire platform jar. Let me try online mode to download the needed test runner.

  29. GLM Assistant

    The tests ran and completed. Let me confirm the test results from the surefire reports.

  30. GLM Assistant

    Both tests pass with the fix. Now let me verify the bug actually existed before the fix by temporarily reverting only the controller change.

  31. GLM Assistant

    Now let me run the temp test against the original (unfixed) controller to confirm the bug reproduces.

  32. GLM Assistant

    Confirmed: the bug reproduces without the fix — both _user_request_ and execute-api paths return 404 "Invalid API id specified". Now let me restore the fix.

  33. GLM Assistant

    Now let me run the broader set of API Gateway tests to ensure nothing is broken by the change.

  34. GLM Assistant

    There are failures in authorizer tests involving Lambda invocations (Docker socket errors). Let me verify these are pre-existing environmental failures by reverting all my changes and running those same tests.

  35. GLM Assistant

    Confirmed — that test fails on the original code too (pre-existing environmental failure due to Docker/Lambda not being available). Not caused by my change. Let me restore my fix.

  36. GLM Assistant

    My fix is restored. Let me run the non-Lambda-dependent API Gateway tests to confirm they pass with my change.

  37. GLM Assistant

    All non-Lambda tests pass. Let me also run the apigatewayv2 tests to ensure the v2 service change doesn't break anything.

  38. GLM Assistant

    WebSocketConnectionsApiTest has 5 errors. Let me check whether these are pre-existing by running them on the original code.

  39. GLM Assistant

    These WebSocket errors are due to Docker not being available (unix socket). Let me confirm they're pre-existing by running on the original code.

  40. GLM Assistant

    Confirmed — the same 5 errors exist on the original code (Docker socket unavailable). These are pre-existing environmental failures, not caused by my change.

    Now let me remove the temporary test file before submitting.

  41. GLM Assistant

    Let me review the final diff of my changes.

  42. GLM Assistant

    The changes look correct. Let me do a final compile check to be safe.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.