🐛 Use rawQueryString for API Gateway v2 to preserve repeated query params - #1473
Open
alexalligator wants to merge 1 commit into
Open
🐛 Use rawQueryString for API Gateway v2 to preserve repeated query params#1473alexalligator wants to merge 1 commit into
alexalligator wants to merge 1 commit into
Conversation
…rams
API Gateway payload format 2.0 has no multiValueQueryStringParameters and
flattens repeated parameters into a comma-joined value in
queryStringParameters (?id=1&id=2 => {"id": "1,2"}).
process_lambda_payload_v2 read that lossy field, so applications saw a
single value "1,2" instead of two, breaking anything relying on repeated
parameters (Wagtail choosers, request.GET.getlist, django-filter, DRF).
Build QUERY_STRING from rawQueryString instead, which API Gateway delivers
verbatim and already percent-encoded, so it is passed through without
urlencode (double-escaping) or unquote (which would destroy a literal &
or = inside a value). This also preserves a literal comma in a single
value, which queryStringParameters cannot express.
The presence check is "rawQueryString" in event_info rather than
truthiness, so an empty query string does not fall through to the legacy
path. Invokers other than API Gateway may send a v2-shaped event with no
rawQueryString; that fallback now uses doseq=True to match the v1
multi-value branch.
zappa/asgi.py calls the same function, so ASGI apps are fixed too, as are
Lambda Function URLs, which use payload format 2.0 regardless of the
apigateway_version setting. v1 (REST API) and ALB are unchanged.
This was invisible to the suite because every v2 fixture used
"rawQueryString": "" and the only v2 QUERY_STRING assertion checked for
"". Adds regression tests at the WSGI, ASGI and handler levels.
Closes zappa#1472
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Author
|
Hi, one more thing: Note that there are existing test failures on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
API Gateway payload format 2.0 has no multiValueQueryStringParameters and flattens repeated parameters into a comma-joined value in queryStringParameters (?id=1&id=2 => {"id": "1,2"}). process_lambda_payload_v2 read that lossy field, so applications saw a single value "1,2" instead of two, breaking anything relying on repeated parameters (Wagtail choosers, request.GET.getlist, django-filter, DRF).
Build QUERY_STRING from rawQueryString instead, which API Gateway delivers verbatim and already percent-encoded, so it is passed through without urlencode (double-escaping) or unquote (which would destroy a literal & or = inside a value). This also preserves a literal comma in a single value, which queryStringParameters cannot express.
The presence check is "rawQueryString" in event_info rather than truthiness, so an empty query string does not fall through to the legacy path. Invokers other than API Gateway may send a v2-shaped event with no rawQueryString; that fallback now uses doseq=True to match the v1 multi-value branch.
zappa/asgi.py calls the same function, so ASGI apps are fixed too, as are Lambda Function URLs, which use payload format 2.0 regardless of the apigateway_version setting. v1 (REST API) and ALB are unchanged.
This was invisible to the suite because every v2 fixture used "rawQueryString": "" and the only v2 QUERY_STRING assertion checked for "". Adds regression tests at the WSGI, ASGI and handler levels.
GitHub Issues
Closes #1472