Jump to solution
Verify

The Fix

pip install pydantic==2.11.0

Based on closed pydantic/pydantic issue #11165 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -1,19 +1,20 @@ from __future__ import annotations +import inspect import os -from collections import defaultdict
repro.py
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
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==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

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…”
@samuelcolvin · 2024-12-21 · source
“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”
@SteinRobert · 2024-12-21 · source
“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…”
@Viicos · 2025-01-29 · source

Failure Signature (Search String)

  • ~~~~~~~~~^^^^^^^^^^^^^^^

Error Message

Stack trace
error.txt
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.txt
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

repro.py
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

When NOT to use: This fix should not be used if the model requires more than the allowed number of validators.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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