The Fix
Raises a TypeError when setting StreamResponse.last_modified to an unsupported type, instead of silently failing.
Based on closed aio-libs/aiohttp issue #10143 · 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 @@
@@ -0,0 +1 @@
+Setting :attr:`aiohttp.web.StreamResponse.last_modified` to an unsupported type will now raise :exc:`TypeError` instead of silently failing -- by :user:`bdraco`.
diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py
index cb3e3717c66..f720af409d1 100644
Option A — Apply the official fix\nRaises a TypeError when setting StreamResponse.last_modified to an unsupported type, instead of silently failing.\nWhen NOT to use: Do not use this fix if backward compatibility with existing behavior is required.\n\n
Why This Fix Works in Production
- Trigger: Raise `TypeError` when `last_modified` gets an unexpected type
- Mechanism: Raises a TypeError when setting StreamResponse.last_modified to an unsupported type, instead of silently failing.
- 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
- Surfaces as: Raise `TypeError` when `last_modified` gets an unexpected type
Proof / Evidence
- GitHub issue: #10143
- Fix PR: https://github.com/aio-libs/aiohttp/pull/10146
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.71
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thought about it some more, and probably ok to backport to 3.12 but not 3.11”
Failure Signature (Search String)
- Raise `TypeError` when `last_modified` gets an unexpected type
Error Message
Stack trace
Error Message
-------------
Raise `TypeError` when `last_modified` gets an unexpected type
What Broke
Users experienced unexpected behavior as unsupported types were silently ignored.
Fix Options (Details)
Option A — Apply the official fix
Raises a TypeError when setting StreamResponse.last_modified to an unsupported type, instead of silently failing.
Fix reference: https://github.com/aio-libs/aiohttp/pull/10146
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if backward compatibility with existing behavior is required.
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.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.