Skip to content

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

Closed

Description

@heathprovost

This was an issue originally raised here: aws/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): https://github.com/awslabs/aws-lambda-rust-runtime/blob/fd2ea235f4adb166422ca5b612c4a1a42a626daa/lambda-http/src/request.rs#L209

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.

Activity

  1. github-actions commented on Oct 11, 2022

    @github-actions

    ⚠️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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions