The Fix
Upgrade to version 0.49.0 or later.
Based on closed Kludex/starlette issue #2977 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -140,10 +140,11 @@ def path_params(self) -> dict[str, Any]:
if not hasattr(self, "_cookies"):
cookies: dict[str, str] = {}
- cookie_header = self.headers.get("cookie")
+ cookie_headers = self.headers.getlist("cookie")
+
...
If there are multiple Cookie header fields after
decompression, these MUST be concatenated into a single octet string
using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
before being passed into a non-HTTP/2 context, such as an HTTP/1.1
connection, or a generic HTTP server application.
Therefore, the following two lists of Cookie header fields are
semantically equivalent.
cookie: a=b; c=d; e=f
cookie: a=b
cookie: c=d
cookie: e=f
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.49.0 or later.\nWhen NOT to use: This fix should not be applied if the application does not require support for multiple cookie headers.\n\n
Why This Fix Works in Production
- Trigger: Request Header cookie parsing doesn't follow RFC 7540 spec
- Mechanism: The code only retrieves the first cookie header instead of concatenating multiple headers as required by RFC 7540
- Why the fix works: Supports multiple cookie headers in the Request.cookies method, ensuring they are concatenated as per RFC 7540. (first fixed release: 0.49.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The code only retrieves the first cookie header instead of concatenating multiple headers as required by RFC 7540
- Production symptom (often without a traceback): Request Header cookie parsing doesn't follow RFC 7540 spec
Proof / Evidence
- GitHub issue: #2977
- Fix PR: https://github.com/kludex/starlette/pull/3029
- First fixed release: 0.49.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.56
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“It seems we need to use getlist instead there. Weird that I didn't see this before. It seems the code we have was inspired by…”
“Hi, I’d like to work on this issue”
Failure Signature (Search String)
- Request Header cookie parsing doesn't follow RFC 7540 spec
- It seems the code we have was inspired by Django 3.1.0, so maybe we can check if Django changed something.
Copy-friendly signature
Failure Signature
-----------------
Request Header cookie parsing doesn't follow RFC 7540 spec
It seems the code we have was inspired by Django 3.1.0, so maybe we can check if Django changed something.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Request Header cookie parsing doesn't follow RFC 7540 spec
It seems the code we have was inspired by Django 3.1.0, so maybe we can check if Django changed something.
Minimal Reproduction
...
If there are multiple Cookie header fields after
decompression, these MUST be concatenated into a single octet string
using the two-octet delimiter of 0x3B, 0x20 (the ASCII string "; ")
before being passed into a non-HTTP/2 context, such as an HTTP/1.1
connection, or a generic HTTP server application.
Therefore, the following two lists of Cookie header fields are
semantically equivalent.
cookie: a=b; c=d; e=f
cookie: a=b
cookie: c=d
cookie: e=f
What Broke
Only the first cookie is processed, leading to potential data loss in cookie information.
Why It Broke
The code only retrieves the first cookie header instead of concatenating multiple headers as required by RFC 7540
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.49.0 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/kludex/starlette/pull/3029
First fixed release: 0.49.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the application does not require support for multiple cookie headers.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.49.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.