The Fix
pip install pydantic==2.11.4
Based on closed pydantic/pydantic issue #11737 · 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%.
@@ -979,7 +979,7 @@ class CustomType:
) -> core_schema.CoreSchema:
return core_schema.with_info_after_validator_function(
- cls.validate, handler(int), field_name=handler.field_name
+ cls.validate, handler(int)
)
from typing import Annotated
from pydantic import AfterValidator, BaseModel, ValidationInfo
def validate_my_field(value: str, info: ValidationInfo):
print(f"{info.field_name} = {value}")
return value
type MyField = Annotated[str, AfterValidator(validate_my_field)]
class MyModel(BaseModel):
field1: MyField
field2: MyField
MyModel.model_validate(
{
"field1": "value1",
"field2": "value2",
}
)
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.4\nWhen NOT to use: Do not use this fix if you rely on the deprecated field_name argument for custom validation logic.\n\n
Why This Fix Works in Production
- Trigger: Incorrect `ValidationInfo.field_name` when using `type` statement
- Mechanism: Resolves the issue of incorrect `ValidationInfo.field_name` by stopping the use of the deprecated `field_name` argument in validator core schemas.
- Why the fix works: Resolves the issue of incorrect `ValidationInfo.field_name` by stopping the use of the deprecated `field_name` argument in validator core schemas. (first fixed release: 2.11.4).
- 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.12 in real deployments (not just unit tests).
- Production symptom (often without a traceback): Incorrect `ValidationInfo.field_name` when using `type` statement
Proof / Evidence
- GitHub issue: #11737
- Fix PR: https://github.com/pydantic/pydantic/pull/11761
- First fixed release: 2.11.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.56
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“With this code trying both type and TypeAlias, MyModel.model_fields looks like this: I can get field1 and field2 to look identical to field3 and field4,…”
“@DouweM great analysis, this is what I had in mind as well”
“There are lots files and functions involved here, across two repos even, so let me break it down so I don't get lost”
Failure Signature (Search String)
- Incorrect `ValidationInfo.field_name` when using `type` statement
- Field validators receive an incorrect value for `field_name` for fields defined with a type alias made with a `type` statement.
Copy-friendly signature
Failure Signature
-----------------
Incorrect `ValidationInfo.field_name` when using `type` statement
Field validators receive an incorrect value for `field_name` for fields defined with a type alias made with a `type` statement.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Incorrect `ValidationInfo.field_name` when using `type` statement
Field validators receive an incorrect value for `field_name` for fields defined with a type alias made with a `type` statement.
Minimal Reproduction
from typing import Annotated
from pydantic import AfterValidator, BaseModel, ValidationInfo
def validate_my_field(value: str, info: ValidationInfo):
print(f"{info.field_name} = {value}")
return value
type MyField = Annotated[str, AfterValidator(validate_my_field)]
class MyModel(BaseModel):
field1: MyField
field2: MyField
MyModel.model_validate(
{
"field1": "value1",
"field2": "value2",
}
)
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Validators incorrectly report the same field name for multiple fields, leading to confusion in validation output.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.4
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/11761
First fixed release: 2.11.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you rely on the deprecated field_name argument for custom validation logic.
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.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.