Jump to solution
Verify

The Fix

pip install pydantic==2.8.0

Based on closed pydantic/pydantic issue #9780 · 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
@@ -256,7 +256,7 @@ def eval_type_backport( """ try: - if sys.version_info >= (3, 12): + if sys.version_info >= (3, 13): return typing._eval_type( # type: ignore
repro.py
from pydantic import BaseModel class SimpleModel(BaseModel): s: str
verify
Re-run: python fail.py
fix.md
Option A — Upgrade to fixed release\npip install pydantic==2.8.0\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: $ python fail.py
  • Mechanism: Fixes the Python version check for `_eval_type` to ensure compatibility with Python 3.12.3.
  • Why the fix works: Fixes the Python version check for `_eval_type` to ensure compatibility with Python 3.12.3. (first fixed release: 2.8.0).
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

  • Shows up under Python 3.12.3 in real deployments (not just unit tests).
  • Surfaces as: $ python fail.py

Proof / Evidence

Discussion

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

“@natehardison, Thanks for catching that. Working on a fix now! Looks like we had a >= 3.12 check instead of a 3.13 check...”
@sydney-runkle · 2024-06-27 · source
“@natehardison, Sure thing! We'll have v2.8 out on Monday with this fix, but you should be able to pull from main and get things working…”
@sydney-runkle · 2024-06-27 · source
“If a decent number of folks seem to be running into this with the beta, I can also do a v2.8.0b2. Let's just see in…”
@sydney-runkle · 2024-06-27 · source

Failure Signature (Search String)

  • $ python fail.py

Error Message

Stack trace
error.txt
Error Message ------------- $ python fail.py Traceback (most recent call last): File "/Users/nateh/fail.py", line 4, in <module> class SimpleModel(BaseModel): File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 200, in __new__ set_model_fields(cls, bases, config_wrapper, types_namespace) File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 469, in set_model_fields fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_fields.py", line 132, in collect_model_fields type_hints = get_cls_type_hints_lenient(cls, types_namespace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 228, in get_cls_type_hints_lenient hints[name] = eval_type_lenient(value, globalns, localns) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nateh/venv/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_lenient return eval_type_backport(value, globalns, localns) ^^^^^^^^^^^ ... (truncated) ...

Minimal Reproduction

repro.py
from pydantic import BaseModel class SimpleModel(BaseModel): s: str

Environment

  • Python: 3.12.3
  • Pydantic: 2.8.0

Fix Options (Details)

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

pip install pydantic==2.8.0

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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

First fixed release: 2.8.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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

Verify Fix

verify
Re-run: python fail.py

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

Related Issues

No related fixes found.

Sources

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