Skip to content

Feature request: Add a flag to ALBResolver to URL-decode query parameters #7621

@chriselion

Description

@chriselion

Use case

(follow up from Discord thread: https://discord.com/channels/1006478942305263677/1432874977454985288)

Background: According to https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html, for ALB requests

If the query parameters are URL-encoded, the load balancer does not decode them. You must decode them in your Lambda function

This decoding should happen before input validation; I think datetime types are especially problematic for this if you're trying to pass them as ISO-format strings. For example: .../?start=2025-12-20T16%3A56%3A02.032000%2000%3A00&end=2025-12-30T16%3A56%3A02.032000%2000%3A00

Solution/User Experience

It would be nice for ALBResolver to optionally do this decoding for you (I understand it could be a behavior change, so you probably wouldn't want it to be enabled by default).

An example of this behavior in some other frameworks that process ALB events:
brefphp/bref#456
fastify/aws-lambda-fastify#91

Alternative solutions

I was able to work around this by adding a middleware for my ALB handler:


from aws_lambda_powertools.middleware_factory import lambda_handler_decorator

@lambda_handler_decorator
def alb_query_parameter_decoder(
    handler: Callable[[dict, LambdaContext], dict],
    event: dict,
    context: LambdaContext,
) -> dict:
    query_params = event.get("queryStringParameters")
    if query_params:
        for k, v in query_params.items():
            try:
                query_params[k] = unquote(v)
            except Exception:
                pass

    return handler(event, context)

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions