The Fix
pip install pydantic==2.11.0
Based on closed pydantic/pydantic issue #11165 · PR/commit linked
@@ -1,19 +1,20 @@
from __future__ import annotations
+import inspect
import os
-from collections import defaultdict
pydantic version: 2.10.2
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /me/.venv/lib/python3.13/site-packages/pydantic
python version: 3.13.0 (main, Oct 7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.1.0.2.5)]
platform: macOS-15.2-arm64-arm-64bit-Mach-O
related packages: pydantic-settings-2.6.1 mypy-1.13.0 fastapi-0.115.5 typing_extensions-4.12.2
commit: unknown
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 should not be used if the model requires more than the allowed number of validators.\n\n
Why This Fix Works in Production
- Trigger: ~~~~~~~~~^^^^^^^^^^^^^^^
- Mechanism: Too many @model_validator functions cause a recursion error due to stack overflow
- Why the fix works: `@model_validator` causes recursion error / `recursion_loop` due to too many validators. (first fixed release: 2.11.0).
Why This Breaks in Prod
- Shows up under Python 3.13 in real deployments (not just unit tests).
- Too many @model_validator functions cause a recursion error due to stack overflow
- Surfaces as: ~~~~~~~~~^^^^^^^^^^^^^^^
Proof / Evidence
- GitHub issue: #11165
- Fix PR: https://github.com/pydantic/pydantic/pull/11244
- 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.35
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Well you're hitting the recursion limit because the model_validator adds a frame to the stack. This is unavoidable. You can manually set a different recursion…”
“We continued the discussion on Slack: https://pydanticlogfire.slack.com/archives/C074GP90D8A/p1734788270247869 According to @samuelcolvin : >Pydantic core validates the core schema generated for a model, using itself”
“https://github.com/pydantic/pydantic/pull/11244 will fix this issue, at least up until a higher number of validators (but we won't be able to do much, unless there's a…”
Failure Signature (Search String)
- ~~~~~~~~~^^^^^^^^^^^^^^^
Error Message
Stack trace
Error Message
-------------
~~~~~~~~~^^^^^^^^^^^^^^^
File ".../python3.13/site-packages/pydantic/_internal/_core_utils.py", line 192, in walk
return f(schema, self._walk)
RecursionError: maximum recursion depth exceeded
Stack trace
Error Message
-------------
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\abc-rHxJY2w_-py3.13\Lib\site-packages\pydantic\_internal\_model_construction.py", line 544, in complete_model_class
schema = gen_schema.clean_schema(schema)
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\abc-rHxJY2w_-py3.13\Lib\site-packages\pydantic\_internal\_generate_schema.py", line 452, in clean_schema
schema = validate_core_schema(schema)
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\abc-rHxJY2w_-py3.13\Lib\site-packages\pydantic\_internal\_core_utils.py", line 568, in validate_core_schema
return _validate_core_schema(schema)
pydantic_core._pydantic_core.SchemaError: Invalid Schema:
function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-after.schema.function-af
... (truncated) ...
Minimal Reproduction
pydantic version: 2.10.2
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /me/.venv/lib/python3.13/site-packages/pydantic
python version: 3.13.0 (main, Oct 7 2024, 05:02:14) [Clang 15.0.0 (clang-1500.1.0.2.5)]
platform: macOS-15.2-arm64-arm-64bit-Mach-O
related packages: pydantic-settings-2.6.1 mypy-1.13.0 fastapi-0.115.5 typing_extensions-4.12.2
commit: unknown
Environment
- Python: 3.13
- Pydantic: 2
What Broke
Application crashes with a recursion error when using many model validators.
Why It Broke
Too many @model_validator functions cause a recursion error due to stack overflow
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/11244
First fixed release: 2.11.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the model requires more than the allowed number of validators.
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.