Jump to solution
Verify

The Fix

pip install pydantic==1.10.19

Based on closed pydantic/pydantic issue #10074 · 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
@@ -51,7 +51,7 @@ from datetime import datetime from pydantic import BaseModel -from pydantic.experimental.pipeline import validate_as, validate_as_deferred +from pydantic.experimental.pipeline import validate_as
repro.py
@lru_cache(maxsize=None) def get_module_ns(module_name: str) -> dict[str, Any]: try: return sys.modules[module_name].__dict__.copy() except KeyError: return {}
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.19\nWhen NOT to use: This fix should not be used if backward compatibility with older versions is required.\n\n

Why This Fix Works in Production

  • Trigger: Right now, we store a `__pydantic_parent_namespace__` attribute on each model when we build the core schema. This cache is used for model rebuilds, resolving…
  • Mechanism: The existing parent namespace logic caused high memory usage and slow build times for large models
  • Why the fix works: Refactor the namespace logic for annotations evaluation to improve performance and support edge cases. (first fixed release: 1.10.19).
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

  • The existing parent namespace logic caused high memory usage and slow build times for large models
  • Production symptom (often without a traceback): Right now, we store a `__pydantic_parent_namespace__` attribute on each model when we build the core schema. This cache is used for model rebuilds, resolving forwardrefs, and typevar substitution.

Proof / Evidence

Discussion

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

“Here's the diff if we want to play with it (with git apply file.diff):”
@Viicos · 2024-08-19 · source
“One idea was to skip building the types namespace (and getting the parent namespace as well) if no stringified annotations are present”
@Viicos · 2024-08-19 · source
“@Viicos, could you push your branch with these changes? I'd love to take a look! Great work here, I think this is worth pursing, but…”
@sydney-runkle · 2024-08-19 · source
“Going to move this to done in regards to our v2.9 work - feels like it's not worth addressing the "edge cases of edge cases"…”
@sydney-runkle · 2024-08-20 · source

Failure Signature (Search String)

  • Right now, we store a `__pydantic_parent_namespace__` attribute on each model when we build the core schema. This cache is used for model rebuilds, resolving forwardrefs, and
Copy-friendly signature
signature.txt
Failure Signature ----------------- Right now, we store a `__pydantic_parent_namespace__` attribute on each model when we build the core schema. This cache is used for model rebuilds, resolving forwardrefs, and typevar substitution. @Viicos, could you push your branch with these changes? I'd love to take a look!

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Right now, we store a `__pydantic_parent_namespace__` attribute on each model when we build the core schema. This cache is used for model rebuilds, resolving forwardrefs, and typevar substitution. @Viicos, could you push your branch with these changes? I'd love to take a look!

Minimal Reproduction

repro.py
@lru_cache(maxsize=None) def get_module_ns(module_name: str) -> dict[str, Any]: try: return sys.modules[module_name].__dict__.copy() except KeyError: return {}

What Broke

Users experienced significant delays in model construction due to inefficient namespace handling.

Why It Broke

The existing parent namespace logic caused high memory usage and slow build times for large models

Fix Options (Details)

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

pip install pydantic==1.10.19

When NOT to use: This fix should not be used if backward compatibility with older versions is required.

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

First fixed release: 1.10.19

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 backward compatibility with older versions is required.

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

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.