The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #10772 · 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%.
@@ -8,6 +8,7 @@
import warnings
from copy import copy, deepcopy
+from functools import cached_property
from typing import (
TYPE_CHECKING,
from pydantic import (
BaseModel,
ConfigDict,
Field,
computed_field,
field_serializer,
model_validator,
)
@dataclass
class CreateCouponInput:
user_id: str
coupon_id: str
amount: int
@computed_field(return_type=int)
@functools.cached_property
def sss(self):
return "haha"
c = CreateCouponInput(user_id="1", coupon_id="2", amount=3)
c.sss = 2
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==1.10.19\nWhen NOT to use: This fix should not be used if the model relies on strict property behavior.\n\n
Why This Fix Works in Production
- Trigger: `cached_property` cannot be assigned by recommended way
- Mechanism: The `cached_property` does not control attribute assignment behavior in Pydantic models
- Why the fix works: Ensures that `cached_property` can be set on Pydantic models, addressing the issue where assignment was not working as expected. (first fixed release: 1.10.19).
- 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.10 in real deployments (not just unit tests).
- The `cached_property` does not control attribute assignment behavior in Pydantic models
- Production symptom (often without a traceback): `cached_property` cannot be assigned by recommended way
Proof / Evidence
- GitHub issue: #10772
- Fix PR: https://github.com/pydantic/pydantic/pull/10774
- First fixed release: 1.10.19
- 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.66
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Indeed, this is annoying”
Failure Signature (Search String)
- `cached_property` cannot be assigned by recommended way
Copy-friendly signature
Failure Signature
-----------------
`cached_property` cannot be assigned by recommended way
Error Message
Signature-only (no traceback captured)
Error Message
-------------
`cached_property` cannot be assigned by recommended way
Minimal Reproduction
from pydantic import (
BaseModel,
ConfigDict,
Field,
computed_field,
field_serializer,
model_validator,
)
@dataclass
class CreateCouponInput:
user_id: str
coupon_id: str
amount: int
@computed_field(return_type=int)
@functools.cached_property
def sss(self):
return "haha"
c = CreateCouponInput(user_id="1", coupon_id="2", amount=3)
c.sss = 2
Environment
- Python: 3.10
- Pydantic: 2
What Broke
Attempting to assign a value to a `cached_property` results in an AttributeError.
Why It Broke
The `cached_property` does not control attribute assignment behavior in Pydantic models
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/10774
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the model relies on strict property behavior.
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
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.10.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.