Jump to solution
Verify

The Fix

pip install pydantic==2.8.0

Based on closed pydantic/pydantic issue #9744 · 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
@@ -307,6 +307,7 @@ def get_function_type_hints( globalns = add_module_globals(function) type_hints = {} + type_params: tuple[Any] = getattr(function, '__type_params__', ()) # type: ignore for name, value in annotations.items(): if include_keys is not None and name not in include_keys:
repro.py
from __future__ import annotations import pydantic class M1(pydantic.BaseModel): x: int M = M1 def foo(): class M2(pydantic.BaseModel): y: str M = M2 class Outer(pydantic.BaseModel): m: M print(repr(Outer(m={'y': 'abc'}))) # Outer(m=M2(y='abc')) @pydantic.validate_call def bar(m: M) -> M: return m print(repr(bar({'x': 1}))) # M1(x=1) foo()
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.8.0\nWhen NOT to use: Do not use this fix if local type hints are not required.\n\n

Why This Fix Works in Production

  • Trigger: `validate_call` doesn't use types from local scope
  • Mechanism: `validate_call` only used types from the global namespace instead of local scope
  • Why the fix works: `validate_call` now correctly uses types from the local scope, addressing the issue where it only utilized types from the global namespace. (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

  • `validate_call` only used types from the global namespace instead of local scope
  • Production symptom (often without a traceback): `validate_call` doesn't use types from local scope

Proof / Evidence

Discussion

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

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description @pydantic.validate_call only uses types from the global namespace, not locals. BaseModel doesn't have this problem. ### Example Code ### Python, Pydantic & OS Ver”
Issue thread · issue description · source

Failure Signature (Search String)

  • `validate_call` doesn't use types from local scope
  • `@pydantic.validate_call` only uses types from the global namespace, not locals. `BaseModel` doesn't have this problem.
Copy-friendly signature
signature.txt
Failure Signature ----------------- `validate_call` doesn't use types from local scope `@pydantic.validate_call` only uses types from the global namespace, not locals. `BaseModel` doesn't have this problem.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- `validate_call` doesn't use types from local scope `@pydantic.validate_call` only uses types from the global namespace, not locals. `BaseModel` doesn't have this problem.

Minimal Reproduction

repro.py
from __future__ import annotations import pydantic class M1(pydantic.BaseModel): x: int M = M1 def foo(): class M2(pydantic.BaseModel): y: str M = M2 class Outer(pydantic.BaseModel): m: M print(repr(Outer(m={'y': 'abc'}))) # Outer(m=M2(y='abc')) @pydantic.validate_call def bar(m: M) -> M: return m print(repr(bar({'x': 1}))) # M1(x=1) foo()

Environment

  • Pydantic: 2

What Broke

Incorrect type validation leading to runtime errors in function calls.

Why It Broke

`validate_call` only used types from the global namespace instead of local scope

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 this fix if local type hints are not 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/9760

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 this fix if local type hints are not 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
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.