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%.
@@ -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.
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"}
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.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).
- 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
- GitHub issue: #9142
- Fix PR: https://github.com/pydantic/pydantic/pull/12327
- First fixed release: 2.12.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.43
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 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.”
“This reminds me of: * https://github.com/pydantic/pydantic/pull/8364 * https://github.com/pydantic/pydantic/pull/8335”
“Hi all, thanks for your feedback here”
Failure Signature (Search String)
- from pydantic import BaseModel, ConfigDict, Field, TypeAdapter
Error Message
Stack trace
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
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
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.
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
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
| Version | Status |
|---|---|
| 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.