The Fix
pip install pydantic==2.11.6
Based on closed pydantic/pydantic issue #12110 · 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%.
@@ -712,8 +712,9 @@ def verify_square(self) -> Self:
def dec(f: Any) -> _decorators.PydanticDescriptorProxy[Any]:
- # auto apply the @classmethod decorator
- f = _decorators.ensure_classmethod_based_on_signature(f)
+ # auto apply the @classmethod decorator (except for *after* validators, which should be instance methods):
from typing import Optional
from pydantic import model_validator, BaseModel
class A(BaseModel):
a: Optional[str] = None
@model_validator(mode="after")
def check(cls, values):
assert values.a is not None
>> A(a="abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
File "<stdin>", line 5, in check
AttributeError: 'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'a'
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.11.6\nWhen NOT to use: This fix should not be applied if the model validator's signature is intended to be a class method.\n\n
Why This Fix Works in Production
- Trigger: from typing import Optional
- Mechanism: The model_validator was incorrectly treated as a class method instead of an instance method
- Why the fix works: Addresses an AttributeError encountered with model validators in Pydantic V2.12.0a1 by ensuring that after model validators are treated as instance methods. (first fixed release: 2.11.6).
- 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 model_validator was incorrectly treated as a class method instead of an instance method
- Surfaces as: from typing import Optional
Proof / Evidence
- GitHub issue: #12110
- Fix PR: https://github.com/pydantic/pydantic/pull/11957
- First fixed release: 2.11.6
- 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.42
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for testing out the beta release”
Failure Signature (Search String)
- from typing import Optional
Error Message
Stack trace
Error Message
-------------
from typing import Optional
from pydantic import model_validator, BaseModel
class A(BaseModel):
a: Optional[str] = None
@model_validator(mode="after")
def check(cls, values):
assert values.a is not None
>> A(a="abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
File "<stdin>", line 5, in check
AttributeError: 'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'a'
Minimal Reproduction
from typing import Optional
from pydantic import model_validator, BaseModel
class A(BaseModel):
a: Optional[str] = None
@model_validator(mode="after")
def check(cls, values):
assert values.a is not None
>> A(a="abc")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
File "<stdin>", line 5, in check
AttributeError: 'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'a'
Environment
- Python: 3.10
- Pydantic: 2
Why It Broke
The model_validator was incorrectly treated as a class method instead of an instance method
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.6
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/11957
First fixed release: 2.11.6
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the model validator's signature is intended to be a class method.
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.11.6 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.