Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The issue is about API Gateway REST API path-based invocation returning 404. The path format /restapis/{id}/{stage}/_user_request_/{path} should route requests through API Gateway to the Lambda function, but instead returns "Invalid API id specified".

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

  3. DeepSeek Assistant

    This looks like a Java project - Floci (a local cloud stack). Let me explore the source and find the relevant API Gateway code.

  4. DeepSeek Assistant

    Let me look for API Gateway related files.

  5. DeepSeek Assistant

    Let me look at the key files related to the _user_request_ path and routing.

  6. DeepSeek Assistant

    Let me use the correct special command: open with proper syntax.

  7. DeepSeek Assistant

    Let me look at the ApiGatewayExecuteController and the AwsServiceRouter.

  8. DeepSeek Assistant

    Let me look at the dispatch method.

  9. DeepSeek Assistant

    Let me look at the dispatch method at line 226.

  10. DeepSeek Assistant

    Now let me look at the AwsServiceRouter to understand how requests are routed to the execute controller. Let me also check how the path /restapis/{apiId}/{stageName}/_user_request_/{proxy} gets routed to the correct controller.

    The issue is that the API Gateway management plane operations (like create-rest-api, get-resources) use the path /restapis/{id}/... but these are separate from the data plane path /restapis/{id}/{stage}/_user_request_/{path}.

    Let me look at the AwsServiceRouter to see how it routes requests.

  11. DeepSeek Assistant

    This AwsServiceRouter is about AWS integration routing, not about request routing. Let me look at the main API Gateway controller.

  12. DeepSeek Assistant

    Let me look for how the ApiGatewayController might be conflicting with the user request controller. Let me check if there's a path conflict

  13. DeepSeek Assistant

    Let me search for the "Invalid API id specified" error message

  14. DeepSeek Assistant

    Let me look at the ApiGatewayService to understand how APIs are stored

  15. DeepSeek Assistant

    Let me look at the getRestApi, createRestApi, and getStage methods

  16. DeepSeek Assistant

    Let me look at these methods in

  17. DeepSeek Assistant

    Let me look at the key methods used for storing:

  18. DeepSeek Assistant

    Now let me look at the apiKey method to understand the key format:

  19. DeepSeek Assistant

    Let me check how region resolution works, and also look at RegionResolver.

  20. DeepSeek Assistant

    Let me look at the integration test for the user request controller

  21. DeepSeek Assistant

    Let me see the rest of the test:

  22. DeepSeek Assistant

    Let me check how createDeployment works in the controller:

  23. DeepSeek Assistant

    Let me look at the createDeployment method in the controller and

  24. DeepSeek Assistant

    Let me go to the right file.

  25. DeepSeek Assistant

    Let me look at the createDeployment method in the service:

  26. DeepSeek Assistant

    I think I found the issue! When creating the API via AWS CLI, the region is resolved from the Authorization header as eu-west-2. But when invoking via curl (which doesn't send an Authorization header), the region falls back to the default region (likely us-east-1). The API was stored under eu-west-2::<apiId>, but looked up under us-east-1::<apiId>, resulting in "Invalid API id specified".

    Let me verify this theory by checking the default region

  27. DeepSeek Assistant

    Let me check the EmulatorConfig to see the default region:

  28. DeepSeek Assistant

    Let me first run the existing integration test to see if the _user_request_ path works in tests

  29. DeepSeek Assistant

    HOME is not set. Let me try setting it.

  30. DeepSeek Assistant

    The test passes, confirming the _user_request_ path works correctly within the test framework. The issue must be about region mismatch: when creating via AWS CLI, the region comes from the Authorization header (e.g., eu-west-2), but when invoking via curl (no Authorization header), the region defaults to us-east-1.

    Let me verify by looking at the StorageBackend to understand how we could search across regions:

  31. DeepSeek Assistant

    Let me look at StorageBackend to understand the available methods.

  32. DeepSeek Assistant

    Let me look at the dispatch method more carefully to understand the full

  33. DeepSeek Assistant

    I need to open the file again.

  34. DeepSeek Assistant

    Let me also look at ApiGatewayV2Service.getApi to see the same pattern

  35. DeepSeek Assistant

    Now I have a clear understanding. Let me implement the fix. The issue is that the dispatch method uses the region from headers to look up the API. When calling via curl (no Authorization header), the region defaults to us-east-1 but the API might be in a different region (like eu-west-2).

    I'll:

    1. Add a findRestApiRegion(String apiId) to ApiGatewayService to find the API across all regions
    2. Add a findApiRegion(String apiId) to ApiGatewayV2Service similarly
    3. Update dispatch to fall back to cross-region search

    First, let me add the cross-region lookup to `ApiGatewayService

  36. DeepSeek Assistant

    Now I'll add the findRestApiRegion method to ApiGatewayService. Let me first check the imports

  37. DeepSeek Assistant

    Now let me implement the changes. First, add the cross-region lookup to ApiGatewayService:

  38. DeepSeek Assistant

    I see an issue - the "::" string was not properly inserted. Let me fix the method:

  39. DeepSeek Assistant

    I need to fix the string literal. Let me use replace to fix it:

  40. DeepSeek Assistant

    Good. Now let me add the same kind of method to ApiGatewayV2Service:

  41. DeepSeek Assistant

    Let me look at the getApi method in ApiGatewayV2Service:

  42. DeepSeek Assistant

    Now let me add findApiRegion to `ApiGatewayV2Service

  43. DeepSeek Assistant

    Now let me modify the dispatch method in ApiGatewayExecuteController to fall back to cross-region lookup:

  44. DeepSeek Assistant

    Now let me modify the dispatch method to support cross-region lookup. I'll replace lines 226-252

  45. DeepSeek Assistant

    The dispatch method now falls back to cross-region lookup. Let me verify the changes compile and the

  46. DeepSeek Assistant

    Good, the test passes. Let me also run a broader set of API Gateway tests to make sure nothing is broken

  47. DeepSeek Assistant

    All tests pass. Now, I also want to address the secondary issue: in AWS, create-deployment --stage-name dev should also create a stage. Let me check if this is already handled or needs fixing

  48. DeepSeek Assistant

    Let me also fix the createDeployment to auto-create a stage when stageName is provided (standard

  49. DeepSeek Assistant

    The edit introduced duplicate code and misplaced the method. Let me revert and redo this properly. Let me first see the current state of the file around the affected area:

  50. DeepSeek Assistant

    Good, reverted. Let me re-apply changes carefully. First, add findRestApiRegion

  51. DeepSeek Assistant

    Good. Now let me update createDeployment to auto-create stage when stageName is provided. Let me look at the current method:

  52. DeepSeek Assistant

    Now let me update createDeployment to auto-create stage when stageName is provided:

  53. DeepSeek Assistant

    Good. Now let me run all the API Gateway tests to make sure everything still works

  54. DeepSeek Assistant

    Let me check if these failures are pre-existing by first reverting my changes and running the same tests

  55. DeepSeek Assistant

    The failures are pre-existing (9 failures without my changes). Let me restore my changes:

  56. DeepSeek Assistant

    Let me run the core API Gateway tests excluding the pre-existing failing one to verify my changes are good:

  57. DeepSeek Assistant

    Let me see which tests are failing:

  58. DeepSeek Assistant

    Let me check if these failures are also pre-existing:

  59. DeepSeek Assistant

    These failures are pre-existing. Let me restore my changes:

  60. DeepSeek Assistant

    Let me also check if the ApiGatewayCustomDomainFilter needs similar changes:

  61. DeepSeek Assistant

    All pre-existing failures are confirmed. Let me now run the key tests once more to make sure everything passes with my

  62. DeepSeek Assistant

    All key tests pass. Let me review the final diff to make sure all changes are correct

  63. DeepSeek Assistant

    The diff looks clean. Let me run the full set of API Gateway tests one more time to confirm everything is good:

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