Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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):
repro.py
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'
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
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

  • 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

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Thanks for testing out the beta release”
@Viicos · 2025-08-01 · source

Failure Signature (Search String)

  • from typing import Optional

Error Message

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

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

When NOT to use: This fix should not be applied if the model validator's signature is intended to be a class method.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

verify
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

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