Jump to solution
Verify

The Fix

pip install pydantic==2.11.8

Based on closed pydantic/pydantic issue #12024 · 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
@@ -288,7 +288,7 @@ By leveraging the new [`type` statement](https://typing.readthedocs.io/en/latest === "Python 3.9 and above" - ```python + ```python {test="skip"} from typing import Annotated
repro.py
from pydantic import BaseModel type A = Annotated[int, Field(default=5)] class M1(BaseModel): a1: A print(M1.model_json_schema().get("required")) # None which is fine to me class M2(BaseModel): a1: A a2: A print(M2.model_json_schema().get("required")) # ['a1', 'a2'] which is weird, I'd expect no required
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.8\nWhen NOT to use: Do not apply this fix if the behavior of required fields is intentionally designed.\n\n

Why This Fix Works in Production

  • Trigger: JSON Schema inconsistently sets Annotated type aliases as required or not
  • Mechanism: The JSON Schema generation inconsistently marks fields as required based on type alias definitions
  • Why the fix works: Emit a warning when field-specific metadata is used in invalid contexts, addressing JSON Schema inconsistencies. (first fixed release: 2.11.8).
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

  • The JSON Schema generation inconsistently marks fields as required based on type alias definitions
  • Production symptom (often without a traceback): JSON Schema inconsistently sets Annotated type aliases as required or not

Proof / Evidence

Discussion

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

“This is actually expected, as per the warning in the documentation”
@Viicos · 2025-06-30 · source
“Warning implemented in https://github.com/pydantic/pydantic/pull/12028.”
@Viicos · 2025-06-30 · source
“A warning sounds great, without it it was fairly confusing, thank you!”
@orcharddweller · 2025-06-30 · source

Failure Signature (Search String)

  • JSON Schema inconsistently sets Annotated type aliases as required or not
  • print(M1.model_json_schema().get("required")) # None which is fine to me
Copy-friendly signature
signature.txt
Failure Signature ----------------- JSON Schema inconsistently sets Annotated type aliases as required or not print(M1.model_json_schema().get("required")) # None which is fine to me

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- JSON Schema inconsistently sets Annotated type aliases as required or not print(M1.model_json_schema().get("required")) # None which is fine to me

Minimal Reproduction

repro.py
from pydantic import BaseModel type A = Annotated[int, Field(default=5)] class M1(BaseModel): a1: A print(M1.model_json_schema().get("required")) # None which is fine to me class M2(BaseModel): a1: A a2: A print(M2.model_json_schema().get("required")) # ['a1', 'a2'] which is weird, I'd expect no required

Environment

  • Pydantic: 2

What Broke

Users experience unexpected required fields in JSON Schema, leading to validation errors.

Why It Broke

The JSON Schema generation inconsistently marks fields as required based on type alias definitions

Fix Options (Details)

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

pip install pydantic==2.11.8

When NOT to use: Do not apply this fix if the behavior of required fields is intentionally designed.

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

First fixed release: 2.11.8

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 apply this fix if the behavior of required fields is intentionally designed.

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

Related Issues

No related fixes found.

Sources

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