Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #9549 · 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
@@ -124,7 +124,7 @@ SET_TYPES: list[type] = [set, typing.Set, collections.abc.MutableSet] FROZEN_SET_TYPES: list[type] = [frozenset, typing.FrozenSet, collections.abc.Set] -DICT_TYPES: list[type] = [dict, typing.Dict, collections.abc.MutableMapping, collections.abc.Mapping] +DICT_TYPES: list[type] = [dict, typing.Dict] IP_TYPES: list[type] = [IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network]
repro.py
import collections.abc import pydantic config = pydantic.ConfigDict(arbitrary_types_allowed=True, strict=True) adapter = pydantic.TypeAdapter(collections.abc.MutableMapping, config=config) adapter.validate_python(collections.UserDict())
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.18\nWhen NOT to use: This fix should not be used if strict mode validation is not required.\n\n

Why This Fix Works in Production

  • Trigger: C:\code\pipelines cratch\venv\Scripts\python.exe C:\code\pipelines cratch\devtools\pydantic_userdict.py
  • Mechanism: Fixes the issue where a type adapter for collections.abc.MutableMapping fails to validate instances of collections.UserDict in strict mode.
  • Why the fix works: Fixes the issue where a type adapter for collections.abc.MutableMapping fails to validate instances of collections.UserDict in strict mode. (first fixed release: 1.10.18).
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

  • Surfaces as: C:\code\pipelines\scratch\venv\Scripts\python.exe C:\code\pipelines\scratch\devtools\pydantic_userdict.py

Proof / Evidence

Discussion

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

“@sydney-runkle, I'm interested in taking a look at this. BTW, can you unassign me from #9100?”
@mikeleppane · 2024-06-03 · source
“@hb2638, Thanks for reporting this. I can reproduce. Looks like a bug. Some more context:”
@sydney-runkle · 2024-06-03 · source
“Could be a good first issue if someone is looking to get their hands dirty with pydantic's internal validation logic. I think MutableMapping should probably…”
@sydney-runkle · 2024-06-03 · source
“In summary, I think the fix might actually be in pydantic, when we do the schema building. The way we do it is a bit…”
@sydney-runkle · 2024-06-09 · source

Failure Signature (Search String)

  • C:\code\pipelines cratch\venv\Scripts\python.exe C:\code\pipelines cratch\devtools\pydantic_userdict.py

Error Message

Stack trace
error.txt
Error Message ------------- C:\code\pipelines\scratch\venv\Scripts\python.exe C:\code\pipelines\scratch\devtools\pydantic_userdict.py Traceback (most recent call last): File "C:\code\pipelines\scratch\devtools\pydantic_userdict.py", line 6, in <module> adapter.validate_python(collections.UserDict()) File "C:\code\pipelines\scratch\venv\Lib\site-packages\pydantic\type_adapter.py", line 260, in validate_python return self.validator.validate_python(object, strict=strict, from_attributes=from_attributes, context=context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.ValidationError: 1 validation error for dict[any,any] Input should be a valid dictionary [type=dict_type, input_value={}, input_type=UserDict] For further information visit https://errors.pydantic.dev/2.7/v/dict_type Process finished with exit code 1

Minimal Reproduction

repro.py
import collections.abc import pydantic config = pydantic.ConfigDict(arbitrary_types_allowed=True, strict=True) adapter = pydantic.TypeAdapter(collections.abc.MutableMapping, config=config) adapter.validate_python(collections.UserDict())

Environment

  • Pydantic: 2

Fix Options (Details)

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

pip install pydantic==1.10.18

When NOT to use: This fix should not be used if strict mode validation is not required.

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

First fixed release: 1.10.18

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 should not be used if strict mode validation is not required.

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

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.