Jump to solution
Details

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

Open PR/Commit
@@ -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
fix.md
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.
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

  • Surfaces as: Raise `TypeError` when `last_modified` gets an unexpected type

Proof / Evidence

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”
@bdraco · 2024-12-08 · source

Failure Signature (Search String)

  • Raise `TypeError` when `last_modified` gets an unexpected type

Error Message

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

When NOT to use: Do not use this fix if backward compatibility with existing behavior is required.

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

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