The Fix
pip install pydantic==2.11.0
Based on closed pydantic/pydantic issue #8785 · PR/commit linked
@@ -15,6 +15,8 @@
from typing_extensions import ParamSpec, TypeAliasType, TypeIs, deprecated, get_args, get_origin
+from pydantic.version import version_short
+
from ._namespace_utils import GlobalsNamespace, MappingNamespace, NsResolver, get_module_ns_of
from pydantic import BaseModel, TypeAdapter
class RecursiveDict(BaseModel):
d: dict[str, 'RecursiveDict']
adapter = TypeAdapter(RecursiveDict)
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.11.0\nWhen NOT to use: This fix is not applicable for non-recursive types or when using BaseModel.\n\n
Why This Fix Works in Production
- Trigger: Recursive `dict` causes infinite recursion during schema generation
- Mechanism: Using recursive types without BaseModel leads to infinite recursion during schema generation
- Why the fix works: Improves the exception message when encountering recursion errors during type evaluation, addressing infinite recursion issues with recursive dict types. (first fixed release: 2.11.0).
Why This Breaks in Prod
- Shows up under Python 3.11 in real deployments (not just unit tests).
- Using recursive types without BaseModel leads to infinite recursion during schema generation
- Production symptom (often without a traceback): Recursive `dict` causes infinite recursion during schema generation
Proof / Evidence
- GitHub issue: #8785
- Fix PR: https://github.com/pydantic/pydantic/pull/11356
- First fixed release: 2.11.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.72
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.11.0
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@nick-griaznov, Hmph, thanks for reporting this. At a first glance, this is definitely something that we want to support, especially because it's something that we…”
“@dmontagu, If you have some extra time this week, I know you mentioned you might be interested in looking into a fix for this.”
“@Viicos, maybe we could revisit this - I feel like this is probably related to the annotation resolution stuff that we've been looking at.”
Failure Signature (Search String)
- Recursive `dict` causes infinite recursion during schema generation
- This will fail:
Copy-friendly signature
Failure Signature
-----------------
Recursive `dict` causes infinite recursion during schema generation
This will fail:
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Recursive `dict` causes infinite recursion during schema generation
This will fail:
Minimal Reproduction
from pydantic import BaseModel, TypeAdapter
class RecursiveDict(BaseModel):
d: dict[str, 'RecursiveDict']
adapter = TypeAdapter(RecursiveDict)
Environment
- Python: 3.11
- Pydantic: 2
What Broke
Infinite recursion causes application crashes and unresponsive behavior during type evaluation.
Why It Broke
Using recursive types without BaseModel leads to infinite recursion during schema generation
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.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/11356
First fixed release: 2.11.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable for non-recursive types or when using BaseModel.
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 |
|---|---|
| 2.11.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.