Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #10069 · 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
@@ -681,33 +681,38 @@ def _model_schema(self, cls: type[BaseModel]) -> core_schema.CoreSchema: model_validators = decorators.model_validators.values() - extras_schema = None - if core_config.get('extra_fields_behavior') == 'allow': - assert cls.__mro__[0] is cls
repro.py
# File: mod2.py from __future__ import annotations from typing import Dict, Any from pydantic import BaseModel, ConfigDict class Bar(BaseModel): model_config = ConfigDict(defer_build=True, extra="allow") __pydantic_extra__: Dict[str, Any]
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: Do not use this fix if the model does not utilize __pydantic_extra__.\n\n

Why This Fix Works in Production

  • Trigger: Failing core schema generation when importing a model with a mock schema from another module
  • Why the fix works: the upstream fix ships in 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

  • Production symptom (often without a traceback): Failing core schema generation when importing a model with a mock schema from another module

Proof / Evidence

Discussion

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

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description This issue can only happen in very specific circumstances and I don't know if it's worth fixing if I don't find a straightforward fix. Consider the following modu”
Issue thread · issue description · source

Failure Signature (Search String)

  • Failing core schema generation when importing a model with a mock schema from another module
  • Running `python mod1.py` will result in the following error:
Copy-friendly signature
signature.txt
Failure Signature ----------------- Failing core schema generation when importing a model with a mock schema from another module Running `python mod1.py` will result in the following error:

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Failing core schema generation when importing a model with a mock schema from another module Running `python mod1.py` will result in the following error:

Minimal Reproduction

repro.py
# File: mod2.py from __future__ import annotations from typing import Dict, Any from pydantic import BaseModel, ConfigDict class Bar(BaseModel): model_config = ConfigDict(defer_build=True, extra="allow") __pydantic_extra__: Dict[str, Any]

Environment

  • Pydantic: 2

What Broke

Running the model results in a NameError due to undefined annotations.

Fix Options (Details)

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

pip install pydantic==1.10.18

When NOT to use: Do not use this fix if the model does not utilize __pydantic_extra__.

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

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

  • Do not use this fix if the model does not utilize __pydantic_extra__.

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.