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%.
@@ -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.
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
)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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).
- 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
- GitHub issue: #9278
- Fix PR: https://github.com/pydantic/pydantic/pull/12233
- First fixed release: 2.12.0
- 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.56
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...”
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
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 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
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
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.
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
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
| Version | Status |
|---|---|
| 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.