Jump to solution
Verify

The Fix

pip install pydantic==2.12.0

Based on closed pydantic/pydantic issue #9142 · 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
@@ -89,6 +89,10 @@ print(ta.validate_python([1, 2])) ``` +Configuration can't be provided if the type adapter directly wraps a type that support it, and a +[usage error](../errors/usage_errors.md) is raised in this case. +The [configuration propagation](#configuration-propagation) rules also apply.
repro.py
from pydantic import BaseModel, ConfigDict, TypeAdapter data1 = [ { "family": "fam", "order": "ord", "specie": "sp1", "ds1": "ds1", }, { "family": "fam", "order": "ord", "specie": "sp2", "ds1": "ds1", }, { "family": "fam", "order": "ord", "specie": "sp3", "ds1": "ds1", }, ] class Model1(BaseModel): family: str | None = None order: str | None = None specie: str | None = None ds1: str = Field(serialization_alias="category") records = TypeAdapter( type=list[Model1], config=ConfigDict(extra="allow"), ).validate_python(data1) print(records[0].model_extra) # -> None // it should be {"extra": "allow"}
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.12.0\nWhen NOT to use: This fix is not applicable if the TypeAdapter wraps a type that already has its own configuration.\n\n

Why This Fix Works in Production

  • Trigger: from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
  • Mechanism: The config keyword in TypeAdapter does not apply when the type is a BaseModel
  • Why the fix works: Clarifies TypeAdapter configuration rules in documentation, addressing the issue where the config keyword in TypeAdapter doesn't update the model. (first fixed release: 2.12.0).
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.11 in real deployments (not just unit tests).
  • The config keyword in TypeAdapter does not apply when the type is a BaseModel
  • Surfaces as: from pydantic import BaseModel, ConfigDict, Field, TypeAdapter

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Hi, I see this is still open. Has this been resolved or not? If not I'd like to take on the documentation part mentioned by…”
@JonathanWindell · 2025-10-04 · confirmation · source
“@JonathanWindell thanks for volunteering. In https://docs.pydantic.dev/latest/concepts/config/#configuration-on-typeadapter, something along the lines of: can be added at the end of the section.”
@Viicos · 2025-10-04 · source
“This reminds me of: * https://github.com/pydantic/pydantic/pull/8364 * https://github.com/pydantic/pydantic/pull/8335”
@sydney-runkle · 2024-04-04 · source
“Hi all, thanks for your feedback here”
@sydney-runkle · 2024-04-02 · source

Failure Signature (Search String)

  • from pydantic import BaseModel, ConfigDict, Field, TypeAdapter

Error Message

Stack trace
error.txt
Error Message ------------- from pydantic import BaseModel, ConfigDict, Field, TypeAdapter data1 = { "family": "fam", "order": "ord", "specie": "sp1", "ds1": "ds1", } class Model1(BaseModel): family: str | None = None order: str | None = None specie: str | None = None ds1: str = Field(serialization_alias="category") results = TypeAdapter( type=Model1, config=ConfigDict(extra="allow"), ).validate_python(data1) print(results) """ pydantic.errors.PydanticUserError: Cannot use `config` when the type is a BaseModel, dataclass or TypedDict. These types can have their own config and setting the config via the `config` parameter to TypeAdapter will not override it, thus the `config` you passed to TypeAdapter becomes meaningless, which is probably not what you want. """

Minimal Reproduction

repro.py
from pydantic import BaseModel, ConfigDict, TypeAdapter data1 = [ { "family": "fam", "order": "ord", "specie": "sp1", "ds1": "ds1", }, { "family": "fam", "order": "ord", "specie": "sp2", "ds1": "ds1", }, { "family": "fam", "order": "ord", "specie": "sp3", "ds1": "ds1", }, ] class Model1(BaseModel): family: str | None = None order: str | None = None specie: str | None = None ds1: str = Field(serialization_alias="category") records = TypeAdapter( type=list[Model1], config=ConfigDict(extra="allow"), ).validate_python(data1) print(records[0].model_extra) # -> None // it should be {"extra": "allow"}

Environment

  • Python: 3.11
  • Pydantic: 2

What Broke

Users experience unexpected behavior when using TypeAdapter with model configurations.

Why It Broke

The config keyword in TypeAdapter does not apply when the type is a BaseModel

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.12.0

When NOT to use: This fix is not applicable if the TypeAdapter wraps a type that already has its own configuration.

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

First fixed release: 2.12.0

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 the TypeAdapter wraps a type that already has its own configuration.

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.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

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