The Fix
pip install pydantic==2.6.4
Based on closed pydantic/pydantic issue #8953 · PR/commit linked
@@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
+from __future__ import annotations
+
+from typing import Literal, Union
Option A — Upgrade to fixed release\npip install pydantic==2.6.4\nWhen NOT to use: This fix should not be used if performance tests are not required for discriminated unions.\n\n
Why This Fix Works in Production
- Trigger: Add performance tests for schema building + data validation -- discriminated union edition
- Mechanism: Improvements to the discriminated union application logic were needed for better performance
- Why the fix works: Adds performance tests for schema building and validation for models with discriminated unions, addressing issue #8953. (first fixed release: 2.6.4).
Why This Breaks in Prod
- Improvements to the discriminated union application logic were needed for better performance
- Production symptom (often without a traceback): Add performance tests for schema building + data validation -- discriminated union edition
Proof / Evidence
- GitHub issue: #8953
- Fix PR: https://github.com/pydantic/pydantic/pull/8955
- First fixed release: 2.6.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.72
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“We've been working on improvements to the discriminated union application logic. It'd be helpful to have performance tests associated with the schema building, as well as for validation against models with discriminated unions!”
Failure Signature (Search String)
- Add performance tests for schema building + data validation -- discriminated union edition
- We've been working on improvements to the discriminated union application logic. It'd be helpful to have performance tests associated with the schema building, as well as for
Copy-friendly signature
Failure Signature
-----------------
Add performance tests for schema building + data validation -- discriminated union edition
We've been working on improvements to the discriminated union application logic. It'd be helpful to have performance tests associated with the schema building, as well as for validation against models with discriminated unions!
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Add performance tests for schema building + data validation -- discriminated union edition
We've been working on improvements to the discriminated union application logic. It'd be helpful to have performance tests associated with the schema building, as well as for validation against models with discriminated unions!
What Broke
Performance issues during schema building and validation led to slow response times.
Why It Broke
Improvements to the discriminated union application logic were needed for better performance
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.6.4
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/8955
First fixed release: 2.6.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if performance tests are not required for discriminated unions.
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
| Version | Status |
|---|---|
| 2.6.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.