Jump to solution
Verify

The Fix

pip install pydantic==2.11.0

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

Jump to Verify Open PR/Commit
@@ -2506,13 +2506,24 @@ def resolve_original_schema(schema: CoreSchema, definitions: _Definitions) -> Co -def _can_be_inlined(def_ref: core_schema.DefinitionReferenceSchema) -> bool: - """Return whether the `'definition-ref'` schema can be replaced by its definition. -
repro.py
from pydantic import BaseModel, Field class Test1(BaseModel): disc: Literal["test1"] class Base(BaseModel): root: Test1 = Field(discriminator="disc") class Reference(BaseModel): field_type: Literal["email"] mapped_fields: list[Base] = Field(default_factory=list)
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.0\nWhen NOT to use: This fix should not be applied if the application relies on the altered behavior of discriminator metadata.\n\n

Why This Fix Works in Production

  • Trigger: Regression in size of pydantic core schemas and corresponding `model_json_schema()` call time
  • Mechanism: The discriminator metadata was not removed, leading to performance regressions in Pydantic core schemas
  • Why the fix works: Fixes a critical issue where the discriminator metadata was not removed, leading to performance regressions in Pydantic core schemas. (first fixed release: 2.11.0).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.10 in real deployments (not just unit tests).
  • The discriminator metadata was not removed, leading to performance regressions in Pydantic core schemas
  • Production symptom (often without a traceback): Regression in size of pydantic core schemas and corresponding `model_json_schema()` call time

Proof / Evidence

Discussion

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

“Thanks for the bug report and for trying out the beta releases”
@Viicos · 2025-03-19 · source
“MRE: Depending on whether Reference is defined (and referencing Base in one of its fields), the core schema of Base is mutated. This is because…”
@Viicos · 2025-03-20 · source

Failure Signature (Search String)

  • Regression in size of pydantic core schemas and corresponding `model_json_schema()` call time
  • When running the example code below, pydantic v2.11.0b2 exhibits an ~140x slowdown compared to pydantic v2.10.6. On my M3 Pro, pydantic v2.10.6 takes 0.561ms to generate the
Copy-friendly signature
signature.txt
Failure Signature ----------------- Regression in size of pydantic core schemas and corresponding `model_json_schema()` call time When running the example code below, pydantic v2.11.0b2 exhibits an ~140x slowdown compared to pydantic v2.10.6. On my M3 Pro, pydantic v2.10.6 takes 0.561ms to generate the model's JSON Schema, but v2.11.0b2 takes 77.07ms.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Regression in size of pydantic core schemas and corresponding `model_json_schema()` call time When running the example code below, pydantic v2.11.0b2 exhibits an ~140x slowdown compared to pydantic v2.10.6. On my M3 Pro, pydantic v2.10.6 takes 0.561ms to generate the model's JSON Schema, but v2.11.0b2 takes 77.07ms.

Minimal Reproduction

repro.py
from pydantic import BaseModel, Field class Test1(BaseModel): disc: Literal["test1"] class Base(BaseModel): root: Test1 = Field(discriminator="disc") class Reference(BaseModel): field_type: Literal["email"] mapped_fields: list[Base] = Field(default_factory=list)

Environment

  • Python: 3.10
  • Pydantic: 2

Why It Broke

The discriminator metadata was not removed, leading to performance regressions in Pydantic core schemas

Fix Options (Details)

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

pip install pydantic==2.11.0

When NOT to use: This fix should not be applied if the application relies on the altered behavior of discriminator metadata.

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

First fixed release: 2.11.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 applied if the application relies on the altered behavior of discriminator metadata.

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

Related Issues

No related fixes found.

Sources

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