Jump to solution
Verify

The Fix

pip install pydantic==1.10.20

Based on closed pydantic/pydantic issue #11641 · 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
@@ -11,7 +11,7 @@ from functools import lru_cache, partial from types import FunctionType -from typing import Any, Callable, Generic, Literal, NoReturn, TypeVar, cast +from typing import Any, Callable, Generic, Literal, NoReturn, cast
repro.py
from typing import TypeVar from pydantic import BaseModel, RootModel ModelT = TypeVar("ModelT", bound=BaseModel) class RootModelIterable(RootModel[list[ModelT]]): def __iter__(self): """Iterates over root items :returns: iterator """ return iter(self.root) def __getitem__(self, item: int): """Gets a root item by position :param item: the position to get :returns: item of type ModelT """ return self.root[item] def __len__(self): """Returns the number of items. :returns: int """ return len(self.root) def append(self, item: ModelT): self.root.append(item)
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.20\nWhen NOT to use: This fix should not be applied if the custom MRO implementation is still required for other models.\n\n

Why This Fix Works in Production

  • Trigger: import RootModelIterable
  • Mechanism: The custom MRO implementation of Pydantic models was removed, causing compatibility issues with generic RootModel subclasses
  • Why the fix works: Removed the custom MRO implementation of Pydantic models, which is no longer necessary due to previous changes. (first fixed release: 1.10.20).
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.12 in real deployments (not just unit tests).
  • The custom MRO implementation of Pydantic models was removed, causing compatibility issues with generic RootModel subclasses
  • Surfaces as: import RootModelIterable

Proof / Evidence

Discussion

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

“ah thanks for the pointer, I'll investigate in that direction. I upgraded to 2.1.1 today”
@flo-ri-an · 2025-03-28 · source
“Could you please describe what worked and what now no longer works?”
@Viicos · 2025-03-28 · source
“Ah, I see you are running Pydantic 2.11.0, but your pydantic-core version is outdated (we have pinned ==* constraints for pydantic-core)”
@Viicos · 2025-03-28 · source
“Oh I see, I'll try to force pydantic-core to update through version constraints”
@flo-ri-an · 2025-03-28 · source

Failure Signature (Search String)

  • import RootModelIterable

Error Message

Stack trace
error.txt
Error Message ------------- import RootModelIterable ./lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:237: in __new__ complete_model_class( ./lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:597: in complete_model_class schema = gen_schema.generate_schema(cls) ./lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:699: in generate_schema schema = self._generate_schema_inner(obj) ./lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:977: in _generate_schema_inner return self._model_schema(obj) ./lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py:809: in _model_schema fields_schema: core_schema.CoreSchema = core_schema.model_fields_schema( E TypeError: model_fields_schema() got an unexpected keyword argument 'extras_keys_schema'

Minimal Reproduction

repro.py
from typing import TypeVar from pydantic import BaseModel, RootModel ModelT = TypeVar("ModelT", bound=BaseModel) class RootModelIterable(RootModel[list[ModelT]]): def __iter__(self): """Iterates over root items :returns: iterator """ return iter(self.root) def __getitem__(self, item: int): """Gets a root item by position :param item: the position to get :returns: item of type ModelT """ return self.root[item] def __len__(self): """Returns the number of items. :returns: int """ return len(self.root) def append(self, item: ModelT): self.root.append(item)

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Generic RootModel subclasses fail to import, leading to test suite failures and broken functionality.

Why It Broke

The custom MRO implementation of Pydantic models was removed, causing compatibility issues with generic RootModel subclasses

Fix Options (Details)

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

pip install pydantic==1.10.20

When NOT to use: This fix should not be applied if the custom MRO implementation is still required for other models.

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

First fixed release: 1.10.20

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 applied if the custom MRO implementation is still required for other models.

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

Related Issues

No related fixes found.

Sources

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