The Fix
pip install pydantic==2.6.1
Based on closed pydantic/pydantic issue #8643 · PR/commit linked
@@ -733,6 +733,7 @@ def __deepcopy__(self: Model, memo: dict[int, Any] | None = None) -> Model:
if not typing.TYPE_CHECKING:
# We put `__getattr__` in a non-TYPE_CHECKING block because otherwise, mypy allows arbitrary attribute access
+ # The same goes for __setattr__ and __delattr__, see: https://github.com/pydantic/pydantic/issues/8643
def __getattr__(self, item: str) -> Any:
from pydantic import BaseModel
class Foo(BaseModel):
some_field: int
def patch_object(foo: Foo) -> None:
# Ohoh, we got the field name wrong...
foo.some_feeld = 42
foo = Foo(some_field=1)
patch_object(foo)
assert foo.some_field == 42
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==2.6.1\nWhen NOT to use: This fix is not suitable if strict type checking is not required.\n\n
Why This Fix Works in Production
- Trigger: error: "Foo" has no attribute "some_feeld"; maybe "some_field"? [attr-defined]
- Mechanism: The __setattr__ method in BaseModel accepts Any, compromising type safety
- Why the fix works: Fixes the type-safety of attribute access in `BaseModel` by moving the `__setattr__` and `__delattr__` methods into a non-TYPE_CHECKING block. (first fixed release: 2.6.1).
- If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).
Why This Breaks in Prod
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The __setattr__ method in BaseModel accepts Any, compromising type safety
- Surfaces as: error: "Foo" has no attribute "some_feeld"; maybe "some_field"? [attr-defined]
Proof / Evidence
- GitHub issue: #8643
- Fix PR: https://github.com/pydantic/pydantic/pull/8651
- First fixed release: 2.6.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“> Update: PR welcome with a fix for this Great, thanks! > we don't think this change will be significantly breaking in any way :)”
“@bluenote10, Thanks for reporting this”
Failure Signature (Search String)
- error: "Foo" has no attribute "some_feeld"; maybe "some_field"? [attr-defined]
Error Message
Stack trace
Error Message
-------------
error: "Foo" has no attribute "some_feeld"; maybe "some_field"? [attr-defined]
Minimal Reproduction
from pydantic import BaseModel
class Foo(BaseModel):
some_field: int
def patch_object(foo: Foo) -> None:
# Ohoh, we got the field name wrong...
foo.some_feeld = 42
foo = Foo(some_field=1)
patch_object(foo)
assert foo.some_field == 42
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Type checkers fail to catch incorrect attribute assignments, leading to runtime errors.
Why It Broke
The __setattr__ method in BaseModel accepts Any, compromising type safety
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.6.1
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/8651
First fixed release: 2.6.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable if strict type checking is not required.
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 |
|---|---|
| 2.6.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.