Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querystrings that have percent encodings get double encoded for Lambda ALB Events in lambda-http #543

Closed
heathprovost opened this issue Oct 10, 2022 · 1 comment · Fixed by #545

Comments

@heathprovost
Copy link

heathprovost commented Oct 10, 2022

This was an issue originally raised here: awslabs/aws-lambda-web-adapter#99. Since the root issue is not in that project but this one I'm moving discussion here.

Problem: Whenever a url that contains a querystring with percent encoded values is passed through lambda-http, it gets double encoded in the newly generated http request if the original event source was an ALB. This is because the Lambda Event for ALBs does not automatically decode querystrings, whereas the same event for API Gateways do:

https://serverless-training.com/articles/api-gateway-vs-application-load-balancer-technical-details/ (about half way down the page)

Note that the keys and values of evt.queryStringParameters will be:

  • already URL decoded for you on API Gateway. e.g. ?foo%5Ba%5D=foo%5B will be { 'foo[a]': [ 'foo[' ] }
  • but not URL decoded on ALB. e.g. ?foo%5Ba%5D=foo%5B will be { 'foo%5Ba%5D': [ 'foo%5B' ] }

Discussion on the original issue lead to the thought that this difference should be handled here (but currently is not):

Some((&alb.multi_value_query_string_parameters, &alb.query_string_parameters)),

Here is an example of a url that triggers this issue:

https://test.com/?originalQueryString=%3FshowAll%3Dtrue

When passed from an API Gateway the url passes through correctly:

https://test.com/?originalQueryString=%3FshowAll%3Dtrue

But if the original source was an ALB you get this instead:

https://test.com/?originalQueryString=%253FshowAll%253Dtrue

Thanks in advance.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for the maintainers of this repository to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant