Jump to solution
Verify

The Fix

pip install pydantic==2.9.1

Based on closed pydantic/pydantic issue #10319 · 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
@@ -319,6 +319,8 @@ def val_func(v: Any) -> Any: ) + return v + schema = cs.no_info_after_validator_function(val_func, schema)
repro.py
from typing import TypeAlias from typing import Annotated from annotated_types import Predicate from pydantic import BaseModel def is_positive(value: int) -> bool: return value > 0 PositiveInt: TypeAlias = Annotated[int, Predicate(is_positive)] class MyModel(BaseModel): foo: PositiveInt m = MyModel.model_validate({'foo': 3}) assert m.foo == 3
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.9.1\nWhen NOT to use: Do not use this fix if you require the previous behavior of `Predicate`.\n\n

Why This Fix Works in Production

  • Trigger: Using `annotated_types.Predicate` gives unexpected result in 2.9.0. The below code fails but works in <2.9.0. Also replacing `PositiveInt` with `Annotated[int,…
  • Mechanism: Fixes an issue with `Predicate` in Pydantic v2.9.0 that caused unexpected results.
  • Why the fix works: Fixes an issue with `Predicate` in Pydantic v2.9.0 that caused unexpected results. (first fixed release: 2.9.1).
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): Using `annotated_types.Predicate` gives unexpected result in 2.9.0. The below code fails but works in <2.9.0. Also replacing `PositiveInt` with `Annotated[int, Gt(0)]` (with `Gt` also from `annotated_types`) does work in 2.9.0.

Proof / Evidence

Discussion

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

“@AckslD, Thanks for reporting this. Indeed, a bug on our end. I've opened https://github.com/pydantic/pydantic/pull/10321 to fix this issue, and we'll roll out the fix in…”
@sydney-runkle · 2024-09-05 · source

Failure Signature (Search String)

  • Using `annotated_types.Predicate` gives unexpected result in 2.9.0. The below code fails but works in <2.9.0. Also replacing `PositiveInt` with `Annotated[int, Gt(0)]` (with `Gt`
  • assert m.foo == 3
Copy-friendly signature
signature.txt
Failure Signature ----------------- Using `annotated_types.Predicate` gives unexpected result in 2.9.0. The below code fails but works in <2.9.0. Also replacing `PositiveInt` with `Annotated[int, Gt(0)]` (with `Gt` also from `annotated_types`) does work in 2.9.0. assert m.foo == 3

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Using `annotated_types.Predicate` gives unexpected result in 2.9.0. The below code fails but works in <2.9.0. Also replacing `PositiveInt` with `Annotated[int, Gt(0)]` (with `Gt` also from `annotated_types`) does work in 2.9.0. assert m.foo == 3

Minimal Reproduction

repro.py
from typing import TypeAlias from typing import Annotated from annotated_types import Predicate from pydantic import BaseModel def is_positive(value: int) -> bool: return value > 0 PositiveInt: TypeAlias = Annotated[int, Predicate(is_positive)] class MyModel(BaseModel): foo: PositiveInt m = MyModel.model_validate({'foo': 3}) assert m.foo == 3

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users experienced validation failures when using `Predicate` with `Annotated` types.

Fix Options (Details)

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

pip install pydantic==2.9.1

When NOT to use: Do not use this fix if you require the previous behavior of `Predicate`.

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

First fixed release: 2.9.1

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 require the previous behavior of `Predicate`.

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

Related Issues

No related fixes found.

Sources

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