The Fix
pip install pydantic==1.10.15
Based on closed pydantic/pydantic issue #9021 · 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%.
@@ -550,7 +550,7 @@ def collect_config(self) -> ModelConfigData: # noqa: C901 (ignore complexity)
if arg_name is None:
continue
- config.update(self.get_config_update(arg_name, arg))
+ config.update(self.get_config_update(arg_name, arg, lax_extra=True))
elif isinstance(stmt.rvalue, DictExpr): # dict literals
# test.py
from pydantic import BaseModel, ConfigDict
def condition() -> bool:
return True
class MyModel(BaseModel):
model_config = ConfigDict(extra="ignore" if condition() else "forbid")
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==1.10.15\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: test.py:10: error: Invalid value for "Config.extra" [pydantic-config]
- Mechanism: Removes an unnecessary warning for the config in the Pydantic mypy plugin, addressing a false positive error related to the 'Config.extra' value.
- Why the fix works: Removes an unnecessary warning for the config in the Pydantic mypy plugin, addressing a false positive error related to the 'Config.extra' value. (first fixed release: 1.10.15).
- 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.12 in real deployments (not just unit tests).
- Production symptom (often without a traceback): test.py:10: error: Invalid value for "Config.extra" [pydantic-config]
Proof / Evidence
- GitHub issue: #9021
- Fix PR: https://github.com/pydantic/pydantic/pull/9039
- First fixed release: 1.10.15
- 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.57
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@Viicos is right; suggested approach compatible with mypy: I haven't confirmed this works but I think it should”
“@Apakottur, Hmm, thanks for reporting this. Seems like a bug, but a pretty minor one. Maybe @dmontagu has an idea for an easy fix...”
“This has to do with how mypy handles union of types (see playground). I don't think Pydantic can do much here. For reference, pyright will…”
“Thanks for the respone @dmontagu , I've tried both your suggestions and they both still give the same error. Does one of them pass without…”
Failure Signature (Search String)
- test.py:10: error: Invalid value for "Config.extra" [pydantic-config]
- Found 1 error in 1 file (checked 1 source file)
Copy-friendly signature
Failure Signature
-----------------
test.py:10: error: Invalid value for "Config.extra" [pydantic-config]
Found 1 error in 1 file (checked 1 source file)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
test.py:10: error: Invalid value for "Config.extra" [pydantic-config]
Found 1 error in 1 file (checked 1 source file)
Minimal Reproduction
# test.py
from pydantic import BaseModel, ConfigDict
def condition() -> bool:
return True
class MyModel(BaseModel):
model_config = ConfigDict(extra="ignore" if condition() else "forbid")
Environment
- Python: 3.12
- Pydantic: 2
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.15
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/9039
First fixed release: 1.10.15
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
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 |
|---|---|
| 1.10.15 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.