Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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
repro.py
# test.py from pydantic import BaseModel, ConfigDict def condition() -> bool: return True class MyModel(BaseModel): model_config = ConfigDict(extra="ignore" if condition() else "forbid")
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.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).
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.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

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”
@dmontagu · 2024-03-15 · source
“@Apakottur, Hmm, thanks for reporting this. Seems like a bug, but a pretty minor one. Maybe @dmontagu has an idea for an easy fix...”
@sydney-runkle · 2024-03-15 · source
“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…”
@Viicos · 2024-03-15 · source
“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…”
@Apakottur · 2024-03-18 · source

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
signature.txt
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.txt
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

repro.py
# 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

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

First fixed release: 1.10.15

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