The Fix
Fixes the issue where saved CookieJars fail to load if they contain partitioned cookies, which are not supported in Python versions below 3.14.
Based on closed aio-libs/aiohttp issue #11523 · 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%.
@@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
+Fix saved ``CookieJar`` fail to be loaded if cookies have ``partitioned`` flag when
+``http.cookie`` does not have partitioned cookies supports. -- by :user:`Cycloctane`.
diff --git a/aiohttp/_cookie_helpers.py b/aiohttp/_cookie_helpers.py
from aiohttp import CookieJar
cj = CookieJar()
cj.update_cookies_from_headers(["a=a; Partitioned"], response_url=URL("http://example.com/"))
cj.save("cookies.bin")
CookieJar().load("cookies.bin")
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nFixes the issue where saved CookieJars fail to load if they contain partitioned cookies, which are not supported in Python versions below 3.14.\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n
Why This Fix Works in Production
- Trigger: self._cookies = pickle.load(f)
- Mechanism: Fixes the issue where saved CookieJars fail to load if they contain partitioned cookies, which are not supported in Python versions below 3.14.
- 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
- Shows up under Python 3.15 in real deployments (not just unit tests).
- Surfaces as: File "D:\Program Files\Python311\Lib\site-packages\aiohttp\cookiejar.py", line 133, in load
Proof / Evidence
- GitHub issue: #11523
- Fix PR: https://github.com/aio-libs/aiohttp/pull/11529
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.57
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I think the patch you are proposing makes sense. There isn't much use for partitioned unless its been monkey patched or 3.14+”
“Yeah, that code is unfortunately complex”
“> I guess partitioned cookies should mostly be unused in Python <3.14 and we can maybe just ignore this issue”
Failure Signature (Search String)
- self._cookies = pickle.load(f)
Error Message
Stack trace
Error Message
-------------
File "D:\Program Files\Python311\Lib\site-packages\aiohttp\cookiejar.py", line 133, in load
self._cookies = pickle.load(f)
^^^^^^^^^^^^^^
File "D:\Program Files\Python311\Lib\http\cookies.py", line 312, in __setitem__
raise CookieError("Invalid attribute %r" % (K,))
http.cookies.CookieError: Invalid attribute 'partitioned'
Minimal Reproduction
from aiohttp import CookieJar
cj = CookieJar()
cj.update_cookies_from_headers(["a=a; Partitioned"], response_url=URL("http://example.com/"))
cj.save("cookies.bin")
CookieJar().load("cookies.bin")
Environment
- Python: 3.15
What Broke
Saved CookieJars fail to load, resulting in cookie access errors.
Fix Options (Details)
Option A — Apply the official fix
Fixes the issue where saved CookieJars fail to load if they contain partitioned cookies, which are not supported in Python versions below 3.14.
Fix reference: https://github.com/aio-libs/aiohttp/pull/11529
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
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 |
|---|---|
| 3.14 | Broken |
| 3.15 | Broken |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.