Replies: 1 comment 3 replies
-
Hey @seed-good! I was unable to reproduce this error here. I deployed the exactly Lambda you sent and I can access the resource correctly. I'm not saying it's not a possible bug or some other issue because I see this is failing in your case, but do you have anything additional to add here to help me reproduce the issue? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Powertools for AWS Lambda with Python 3.10 and Powertools layer version 52 (but I can replicate this issue in layer version 71 as well). My lambda event router (APIGatewayRestResolver) uses regex because I need the same method to handle both /v1/foo as well as just /foo. My decorator for this looks like: @app.get("/v[0-9]/foo|/foo") (the [0-9] is just for future possibilities). This works fine except when I have a nested resource with a similar regex. If my nested resource is "bar", my method decorator for the method that needs to handle /foo/bar as well as /v1/foo/bar looks like @app.get("/v[0-9]/foo/bar|/foo/bar"). Attached is a simple lambda func to demo this.
The issue is that calls with path "/v1/foo/bar" get handled by the method for foo instead of the method for foo/bar.
To summarize:
The following work correctly (i.e. get routed to the right method):
/foo, /v1/foo, /foo/bar
The only path that does not get routed correctly is /v1/foo/bar
You can use the following API gateway URLs to see this. The response is either "got foo" or "got foo bar" depending on which of the 2 methods got invoked:
https://8viuioi1oe.execute-api.us-east-1.amazonaws.com/v1/foo
https://8viuioi1oe.execute-api.us-east-1.amazonaws.com/v1/foo/bar
https://8viuioi1oe.execute-api.us-east-1.amazonaws.com/v1/v1/foo
https://8viuioi1oe.execute-api.us-east-1.amazonaws.com/v1/v1/foo/bar
I am perplexed how /foo/bar gets routed correctly but the regex version /v1/foo/bar does not.
Any help/explanation will be appreciated!
test-regex-lambda.zip
Beta Was this translation helpful? Give feedback.
All reactions