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%.
@@ -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
# 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]
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==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.
- 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
- GitHub issue: #10069
- Fix PR: https://github.com/pydantic/pydantic/pull/10070
- First fixed release: 1.10.18
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.49
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”
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
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 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
# 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
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.
When NOT to Use This Fix
- Do not use this fix if the model does not utilize __pydantic_extra__.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 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.