Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.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")
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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.
Production impact:
  • 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

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+”
@bdraco · 2025-09-20 · source
“Yeah, that code is unfortunately complex”
@Dreamsorcerer · 2025-09-18 · source
“> I guess partitioned cookies should mostly be unused in Python <3.14 and we can maybe just ignore this issue”
@Cycloctane · 2025-09-20 · source

Failure Signature (Search String)

  • self._cookies = pickle.load(f)

Error Message

Stack trace
error.txt
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

repro.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")

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.

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

Fix reference: https://github.com/aio-libs/aiohttp/pull/11529

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

Verify Fix

verify
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

VersionStatus
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.