Jump to solution
Verify

The Fix

pip install pydantic==2.12.0

Based on closed pydantic/pydantic issue #12230 · 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
@@ -19,7 +19,7 @@ # Keep this in sync with the version constraint in the `pyproject.toml` dependencies: -_COMPATIBLE_PYDANTIC_CORE_VERSION = '2.38.0' +_COMPATIBLE_PYDANTIC_CORE_VERSION = '2.40.1'
repro.py
from pydantic import BaseModel from abc import ABC, abstractmethod class ABC_1(BaseModel, ABC): @abstractmethod def do_something(self): pass class ABC_2(BaseModel, ABC): @abstractmethod def do_something_else(self): pass class A1(ABC_1): def do_something(self): print("Doing something in A1") class A2(ABC_2): def do_something_else(self): print("Doing something else in A2") class X(BaseModel): x: ABC_1 | ABC_2 a1 = A1() a2 = A2() x1 = X(x=a1) x2 = X(x=a2)
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.12.0\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it before the final release.
  • Mechanism: Bumped `pydantic-core` to v2.40.1 to resolve issues with ABC Union support in Pydantic v2.12.
  • Why the fix works: Bumped `pydantic-core` to v2.40.1 to resolve issues with ABC Union support in Pydantic v2.12. (first fixed release: 2.12.0).
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

  • Production symptom (often without a traceback): Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it before the final release.

Proof / Evidence

Discussion

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

“Bisected to https://github.com/pydantic/pydantic-core/commit/4760f383a037e5fe91b854f9d883c7475b0f53f5 (https://github.com/pydantic/pydantic-core/pull/1692). Fixed in core, regression test in https://github.com/pydantic/pydantic/pull/12314.”
@Viicos · 2025-10-02 · confirmation · source
“I want to work on this task and I think it makes sense. Do you agree that we should have this feature? @Viicos”
@pipinstalled · 2025-09-09 · source
“Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it…”
@Viicos · 2025-09-09 · source

Failure Signature (Search String)

  • Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it before the final release.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it before the final release.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Yes this seems like a regression, feel free to take a look although it might not be trivial. In any case, I'll look into it before the final release.

Minimal Reproduction

repro.py
from pydantic import BaseModel from abc import ABC, abstractmethod class ABC_1(BaseModel, ABC): @abstractmethod def do_something(self): pass class ABC_2(BaseModel, ABC): @abstractmethod def do_something_else(self): pass class A1(ABC_1): def do_something(self): print("Doing something in A1") class A2(ABC_2): def do_something_else(self): print("Doing something else in A2") class X(BaseModel): x: ABC_1 | ABC_2 a1 = A1() a2 = A2() x1 = X(x=a1) x2 = X(x=a2)

Environment

  • Pydantic: 2

What Broke

Users experienced failures when using ABC Union in Pydantic models, leading to application errors.

Fix Options (Details)

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

pip install pydantic==2.12.0

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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

First fixed release: 2.12.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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

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

Related Issues

No related fixes found.

Sources

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