Jump to solution
Verify

The Fix

pip install pydantic==2.12.0

Based on closed pydantic/pydantic issue #9278 · 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
@@ -270,6 +270,8 @@ The configuration can take three values: The `__pydantic_extra__` can explicitly be annotated to provide validation for extra fields. +The validation methods (e.g. [`model_validate()`][pydantic.main.BaseModel.model_validate]) have an optional `extra` argument that will override the `extra` configuration value of the model for that validation call. + For more details, refer to the [`extra`][pydantic.ConfigDict.extra] API documentation.
repro.py
SomeModel(BaseModel): my_field: int model_config = ConfigDict(extra="allow") data = SomeModel.model_validate( {"myfield": 1, "extra field": 2}, extra="forbid" # override model config and forbid extra fields just this time )
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: This fix should not be used if the model's extra configuration is intended to be static.\n\n

Why This Fix Works in Production

  • Trigger: Configure behavior for extra fields at runtime / validation time
  • Mechanism: The model validation did not allow dynamic configuration of extra fields at runtime
  • Why the fix works: Adds an extra parameter to the validation functions, allowing dynamic configuration of extra fields during validation. (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

  • The model validation did not allow dynamic configuration of extra fields at runtime
  • Production symptom (often without a traceback): Configure behavior for extra fields at runtime / validation time

Proof / Evidence

Discussion

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

“I wonder if this falls in the V3 bucket, I think we might want to reconsider the relationship between config settings and runtime options...”
@sydney-runkle · 2024-04-18 · source

Failure Signature (Search String)

  • Configure behavior for extra fields at runtime / validation time
  • I would like to change the `extra` configuration of a model dynamically at runtime / validation time.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Configure behavior for extra fields at runtime / validation time I would like to change the `extra` configuration of a model dynamically at runtime / validation time.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Configure behavior for extra fields at runtime / validation time I would like to change the `extra` configuration of a model dynamically at runtime / validation time.

Minimal Reproduction

repro.py
SomeModel(BaseModel): my_field: int model_config = ConfigDict(extra="allow") data = SomeModel.model_validate( {"myfield": 1, "extra field": 2}, extra="forbid" # override model config and forbid extra fields just this time )

What Broke

Users faced validation errors when extra fields were present in the input data.

Why It Broke

The model validation did not allow dynamic configuration of extra fields at runtime

Fix Options (Details)

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

pip install pydantic==2.12.0

When NOT to use: This fix should not be used if the model's extra configuration is intended to be static.

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

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

  • This fix should not be used if the model's extra configuration is intended to be static.

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.