Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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}
repro.py
# %% 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'}
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.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).
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.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

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
affected (exit=None)
fixed (exit=0)

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...”
@sydney-runkle · 2024-06-12 · source
“Tracking in https://github.com/pydantic/pydantic/issues/12557.”
@Viicos · 2025-11-20 · source
“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”
@Stormageddon37 · 2025-10-03 · source

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

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

When NOT to use: This fix is not applicable if you need to preserve extra fields in RootModel.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if you need to preserve extra fields in RootModel.

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