Fix merge_headers() joining multiple Cookie headers with ", " - #1467
Open
kimgunnn wants to merge 3 commits into
Open
Fix merge_headers() joining multiple Cookie headers with ", "#1467kimgunnn wants to merge 3 commits into
kimgunnn wants to merge 3 commits into
Conversation
Cookies are separated by "; ", not commas. HTTP/2 clients may split the cookie header into multiple field lines, and joining them back with ", " produces a Cookie header that WSGI frameworks cannot parse, which breaks session authentication (e.g. Django login loops). The payload v2 path already joins event["cookies"] with "; "; this brings the v1 path in line. Fixes zappa#1466
kimgunnn
force-pushed
the
fix/cookie-header-merge
branch
from
July 21, 2026 01:08
6af9421 to
74b9e12
Compare
monkut
requested changes
Jul 29, 2026
Collaborator
There was a problem hiding this comment.
The fix itself is correct and verified.
Requesting a few small changes to align with project conventions before merge:
- Add a lowercase
cookietest case. The new test uses"Cookie", but the real-world HTTP/2 shape (and the reproduction in #1466) is lowercase"cookie"— which is exactly what theh.lower()branch exists to handle, and it's currently untested. A second assertion or a parametrized case with{"multiValueHeaders": {"cookie": [...]}}would cover it.
Optional, non-blocking: the existing merge_headers tests live in tests/test_handler.py (test_merge_headers_no_multi_value etc.). Since the function lives in zappa/utilities.py, the new tests' placement in tests/test_utilities.py is reasonable — but consider moving the old ones alongside them in a follow-up so coverage of the function isn't split across two files.
Author
|
Good catch — added the lowercase case via subTest so both spellings are covered. Re: consolidating the existing merge_headers tests from test_handler.py, happy to do that in a follow-up PR. |
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
Fixes #1466
merge_headers()joins all multi-value headers with", ",including
Cookie— but cookies are separated by"; ", not commas.HTTP/2 clients such as Chrome may split the cookie header into multiple field lines,
which API Gateway payload v1 delivers via
multiValueHeaders.Zappa then reassembles them as
csrftoken=A, sessionid=B,which WSGI frameworks cannot parse —
sessionidis silently dropped and session auth breaks (e.g. Django login loops).The payload v2 path already joins
event["cookies"]with"; "(
zappa/wsgi.py), so this change brings v1 in line with v2.GitHub Issues
#1466