Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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) )
repro.py
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", } )
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.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).
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.12 in real deployments (not just unit tests).
  • Production symptom (often without a traceback): Incorrect `ValidationInfo.field_name` when using `type` statement

Proof / Evidence

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 · 2025-04-14 · source
“@DouweM great analysis, this is what I had in mind as well”
@Viicos · 2025-04-15 · source
“There are lots files and functions involved here, across two repos even, so let me break it down so I don't get lost”
@DouweM · 2025-04-14 · source

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
signature.txt
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.txt
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

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

When NOT to use: Do not use this fix if you rely on the deprecated field_name argument for custom validation logic.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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.4 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.