The Fix
pip install pydantic==2.2.1
Based on closed pydantic/pydantic issue #9645 · 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%.
@@ -900,7 +900,7 @@ except PydanticUserError as exc_info:
```
-## `config` is unused with TypeAdapter {#type-adapter-config-unused}
+## `config` is unused with `TypeAdapter` {#type-adapter-config-unused}
# %%
import pydantic
from pydantic.dataclasses import dataclass
# %%
class A(pydantic.BaseModel):
model_config = pydantic.ConfigDict(extra="allow")
name: str
a = A(name="a", i=42)
# %%
a.model_extra
# {'i': 42}
# %%
a.model_dump()
# {'name': 'a', 'i': 42}
# %%
@dataclass(config=pydantic.ConfigDict(extra="allow"))
class B:
name: str
b = B(name="a", i=42)
# %%
pydantic.RootModel[type(b)](b).model_extra
# None
# %%
pydantic.RootModel[type(b)](b).model_dump()
# {'name': 'a'}
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.2.1\nWhen NOT to use: This fix is not applicable if you need to preserve extra fields in RootModel.\n\n
Why This Fix Works in Production
- Trigger: `RootModel` from `dataclass` does not preserve extra fields
- Mechanism: RootModel does not preserve extra fields when created from a dataclass with extra='allow'
- Why the fix works: Addresses the issue where `RootModel` does not preserve extra fields when created from a dataclass with `extra='allow'`. (first fixed release: 2.2.1).
- 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.9 in real deployments (not just unit tests).
- RootModel does not preserve extra fields when created from a dataclass with extra='allow'
- Production symptom (often without a traceback): `RootModel` from `dataclass` does not preserve extra fields
Proof / Evidence
- GitHub issue: #9645
- Fix PR: https://github.com/pydantic/pydantic/pull/6937
- First fixed release: 2.2.1
- 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.60
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.2.1
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hmm, my first thought is that RootModel doesn't support the extra specification in config...”
“Tracking in https://github.com/pydantic/pydantic/issues/12557.”
“I've been looking into this in my search for a good **pydantic-core** issue to get into and it seems to be intentional, not a bug”
Failure Signature (Search String)
- `RootModel` from `dataclass` does not preserve extra fields
- Hmm, my first thought is that `RootModel` doesn't support the `extra` specification in `config`...
Copy-friendly signature
Failure Signature
-----------------
`RootModel` from `dataclass` does not preserve extra fields
Hmm, my first thought is that `RootModel` doesn't support the `extra` specification in `config`...
Error Message
Signature-only (no traceback captured)
Error Message
-------------
`RootModel` from `dataclass` does not preserve extra fields
Hmm, my first thought is that `RootModel` doesn't support the `extra` specification in `config`...
Minimal Reproduction
# %%
import pydantic
from pydantic.dataclasses import dataclass
# %%
class A(pydantic.BaseModel):
model_config = pydantic.ConfigDict(extra="allow")
name: str
a = A(name="a", i=42)
# %%
a.model_extra
# {'i': 42}
# %%
a.model_dump()
# {'name': 'a', 'i': 42}
# %%
@dataclass(config=pydantic.ConfigDict(extra="allow"))
class B:
name: str
b = B(name="a", i=42)
# %%
pydantic.RootModel[type(b)](b).model_extra
# None
# %%
pydantic.RootModel[type(b)](b).model_dump()
# {'name': 'a'}
Environment
- Python: 3.9
- Pydantic: 2
What Broke
Extra fields are lost during serialization, leading to incomplete data representation.
Why It Broke
RootModel does not preserve extra fields when created from a dataclass with extra='allow'
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.2.1
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/6937
First fixed release: 2.2.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if you need to preserve extra fields in RootModel.
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.2.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.