APIGW: fix AWS_PROXY payload with Custom Domains #12296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
As we got a report in #12295, we had an issue if our path handling when working with API Gateway Custom Domains and REST APIs.
This PR is a small fix to manage the Lambda Input payload
path
value, which is quite frankly weird, even for AWS.See this comment: #12295 (comment)
path
:/your-path
-> stage is strippedrequestContext.path
:/<stage>/your-path
path
:/<stage>/your-path
-> stage is not strippedrequestContext.path
:/<stage>/your-path
path
:/<basePath>/<stage>/example/v1
-> nothing is strippedrequestContext.path
:/<basePath>/<stage>/example/v1
path
:/<basePath>/example/v1
-> note that they strip the stage in that case when the stage is specifiedrequestContext.path
:/<basePath>/example/v1
-> the stage is even stripped here? which is not following "the rules"So this PR implements the behavior that if a
basePath
is configured and present (meaning you're invoking from a Custom Domain), you need to use therequestContext.path
, because our internal contextinvocation_request["path"]
is used for routing, it should only have the resource path values.I think there might be somewhat of an issue in the lambda payload construction in AWS, and even in the
requestContext
, I think there might be some bug in their implementation 😅Changes
path
field for theAWS_PROXY
payload