Jump to solution
Verify

The Fix

pip install pydantic==2.4.0

Based on closed pydantic/pydantic issue #11104 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -280,14 +280,14 @@ being validated. Some of these arguments have been removed from `@field_validato ```python -from pydantic import BaseModel, FieldValidationInfo, field_validator +from pydantic import BaseModel, ValidationInfo, field_validator
repro.py
from typing import Annotated from pydantic import Field, ValidatorFunctionWrapHandler, WrapValidator def validate_int(absolute: bool) -> WrapValidator: def validate(value: Any, handler: ValidatorFunctionWrapHandler) -> int: validated_value: int = handler(value) return abs(validated_value) if absolute else validated_value if absolute: return WrapValidator( validate, json_schema_input_type=Annotated[int, Field(json_schema_extra={'absolute': True})] ) else: return WrapValidator(validate) AbsoluteValidator = Annotated[int, validate_int(absolute=True)] ta = TypeAdapter(AbsoluteValidator) ta.validate_python(-1) #> 1 ta.json_schema() #> {'type': 'integer', 'absolute': True}
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.4.0\nWhen NOT to use: This fix should not be used if the validator logic relies on the previous behavior of not having `model_type`.\n\n

Why This Fix Works in Production

  • Trigger: Currently, `field_name`, `data`, and `model_config` are provided in `ValidationInfo` of field validators, and where applicable have their values.
  • Mechanism: The `model_type` was not accessible in validators, limiting their functionality
  • Why the fix works: Allows access to `field_name` and `data` in all validators if there is data and a field name, enhancing the functionality of validators in Pydantic. (first fixed release: 2.4.0).

Why This Breaks in Prod

  • The `model_type` was not accessible in validators, limiting their functionality
  • Production symptom (often without a traceback): Currently, `field_name`, `data`, and `model_config` are provided in `ValidationInfo` of field validators, and where applicable have their values.

Proof / Evidence

Discussion

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

“Just to include a bit more of an easier to read example: On the other hand, the following works because the validator is a class…”
@dennispg · 2024-12-13 · source
“Even just the applicable FieldInfo from model_fields would be a big help if for any reason the full model_fields is a bridge to far to…”
@dennispg · 2024-12-16 · source
“Unfortunetly i'm not able to help implement new features, but maybe you can elaborate on why creating PydanticThirdPartyType as BaseModel itself is no solution? Nested…”
@AdunSG · 2024-12-16 · source
“@AdunSG, I simply tried to provide trivial examples here to illustrate what I am asking for”
@dennispg · 2024-12-16 · source

Failure Signature (Search String)

  • Currently, `field_name`, `data`, and `model_config` are provided in `ValidationInfo` of field validators, and where applicable have their values.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Currently, `field_name`, `data`, and `model_config` are provided in `ValidationInfo` of field validators, and where applicable have their values. def validate_length(value: Any, info: ValidationInfo):

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Currently, `field_name`, `data`, and `model_config` are provided in `ValidationInfo` of field validators, and where applicable have their values. def validate_length(value: Any, info: ValidationInfo):

Minimal Reproduction

repro.py
from typing import Annotated from pydantic import Field, ValidatorFunctionWrapHandler, WrapValidator def validate_int(absolute: bool) -> WrapValidator: def validate(value: Any, handler: ValidatorFunctionWrapHandler) -> int: validated_value: int = handler(value) return abs(validated_value) if absolute else validated_value if absolute: return WrapValidator( validate, json_schema_input_type=Annotated[int, Field(json_schema_extra={'absolute': True})] ) else: return WrapValidator(validate) AbsoluteValidator = Annotated[int, validate_int(absolute=True)] ta = TypeAdapter(AbsoluteValidator) ta.validate_python(-1) #> 1 ta.json_schema() #> {'type': 'integer', 'absolute': True}

What Broke

Validators failed to access necessary metadata, causing incorrect validation behavior.

Why It Broke

The `model_type` was not accessible in validators, limiting their functionality

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.4.0

When NOT to use: This fix should not be used if the validator logic relies on the previous behavior of not having `model_type`.

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/7542

First fixed release: 2.4.0

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 used if the validator logic relies on the previous behavior of not having `model_type`.

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.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
2.4.0 Fixed

Related Issues

No related fixes found.

Sources

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