Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #9872 · 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
@@ -80,7 +80,7 @@ from ._schema_generation_shared import CallbackGetCoreSchemaHandler from ._typing_extra import is_finalvar, is_self_type, is_zoneinfo_type -from ._utils import lenient_issubclass +from ._utils import lenient_issubclass, smart_deepcopy
repro.py
pydantic version: 2.8.2 pydantic-core version: 2.20.1 pydantic-core build: profile=release pgo=true install path: /Users/willholloway/.pyenv/versions/3.11.4/envs/medra/lib/python3.11/site-packages/pydantic python version: 3.11.4 (main, Jan 5 2024, 18:07:48) [Clang 15.0.0 (clang-1500.1.0.2.5)] platform: macOS-14.2.1-arm64-arm-64bit related packages: pyright-1.1.369 typing_extensions-4.8.0 fastapi-0.104.1 commit: unknown
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==1.10.18\nWhen NOT to use: This fix should not be used if the discriminator is not properly defined in the union models.\n\n

Why This Fix Works in Production

  • Trigger: Union discrimination ignored in Sequence validation
  • Mechanism: The annotation `Sequence` ignores `discriminator` metadata in certain cases, leading to incorrect validation errors
  • Why the fix works: Fixes a bug where the annotation `Sequence` ignores `discriminator` metadata in certain cases, leading to incorrect validation errors. (first fixed release: 1.10.18).
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.11 in real deployments (not just unit tests).
  • The annotation `Sequence` ignores `discriminator` metadata in certain cases, leading to incorrect validation errors
  • Production symptom (often without a traceback): Union discrimination ignored in Sequence validation

Proof / Evidence

Discussion

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

“Confirmed, this is definitely a bug. Good catch!”
@sydney-runkle · 2024-07-18 · source
“Ah, problem is with the schema gen, the python schema doesn't get transformed to have a tagged-union:”
@sydney-runkle · 2024-07-18 · source
“Cool first issue for someone to work on, if they're interested in diving into schema building!”
@sydney-runkle · 2024-07-18 · source

Failure Signature (Search String)

  • Union discrimination ignored in Sequence validation
  • When validating a sequence of a discriminated union type the discrimination is ignored and validation errors are raised for "missing" fields from the other union cases.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Union discrimination ignored in Sequence validation When validating a sequence of a discriminated union type the discrimination is ignored and validation errors are raised for "missing" fields from the other union cases.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Union discrimination ignored in Sequence validation When validating a sequence of a discriminated union type the discrimination is ignored and validation errors are raised for "missing" fields from the other union cases.

Minimal Reproduction

repro.py
pydantic version: 2.8.2 pydantic-core version: 2.20.1 pydantic-core build: profile=release pgo=true install path: /Users/willholloway/.pyenv/versions/3.11.4/envs/medra/lib/python3.11/site-packages/pydantic python version: 3.11.4 (main, Jan 5 2024, 18:07:48) [Clang 15.0.0 (clang-1500.1.0.2.5)] platform: macOS-14.2.1-arm64-arm-64bit related packages: pyright-1.1.369 typing_extensions-4.8.0 fastapi-0.104.1 commit: unknown

Environment

  • Python: 3.11
  • Pydantic: 2

What Broke

Validation errors are raised for missing fields from other union cases during sequence validation.

Why It Broke

The annotation `Sequence` ignores `discriminator` metadata in certain cases, leading to incorrect validation errors

Fix Options (Details)

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

pip install pydantic==1.10.18

When NOT to use: This fix should not be used if the discriminator is not properly defined in the union models.

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

First fixed release: 1.10.18

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 used if the discriminator is not properly defined in the union models.

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
1.10.18 Fixed

Related Issues

No related fixes found.

Sources

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