Jump to solution
Verify

The Fix

pip install pydantic==1.10.19

Based on closed pydantic/pydantic issue #10618 · 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
@@ -767,6 +767,12 @@ def _unpack_refs_defs(self, schema: CoreSchema) -> CoreSchema: return schema + def _resolve_self_type(self, obj: Any) -> Any: + obj = self.model_type_stack.get() + if obj is None:
repro.py
Traceback (most recent call last): File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module> class A(BaseModel): File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__ complete_model_class( File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class cls.__pydantic_validator__ = create_schema_validator( ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator return SchemaValidator(schema, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.SchemaError: Error building "model" validator: SchemaError: Error building "model-fields" validator: SchemaError: Field "self_field": SchemaError: Error building "is-subclass" validator: TypeError: '_SpecialForm' object cannot be converted to 'PyType'
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 the model relies on unsupported type constructs.\n\n

Why This Fix Works in Production

  • Trigger: class A(BaseModel):
  • Mechanism: The usage of `type[Self]` caused a TypeError due to improper handling in the schema validator
  • Why the fix works: Supports the usage of `type` with `typing.Self` and type aliases, fixing errors related to these types. (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 usage of `type[Self]` caused a TypeError due to improper handling in the schema validator
  • Surfaces as: Traceback (most recent call last):

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 ### Traceback ### Example Code ### Python, Pydantic & OS Version”
Issue thread · issue description · source

Failure Signature (Search String)

  • class A(BaseModel):

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module> class A(BaseModel): File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__ complete_model_class( File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class cls.__pydantic_validator__ = create_schema_validator( ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator return SchemaValidator(schema, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.SchemaError: Error building "model" validator: SchemaError: Error building "model-fields" validator: SchemaError: Field "self_field": SchemaError: Error building "is-subclass" validator: TypeError: '_SpecialForm' object cannot be converted to 'PyType'

Minimal Reproduction

repro.py
Traceback (most recent call last): File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module> class A(BaseModel): File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 227, in __new__ complete_model_class( File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\_internal\_model_construction.py", line 679, in complete_model_class cls.__pydantic_validator__ = create_schema_validator( ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\kchon\OneDrive\Desktop\pydantic\pydantic\plugin\_schema_validator.py", line 50, in create_schema_validator return SchemaValidator(schema, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pydantic_core._pydantic_core.SchemaError: Error building "model" validator: SchemaError: Error building "model-fields" validator: SchemaError: Field "self_field": SchemaError: Error building "is-subclass" validator: TypeError: '_SpecialForm' object cannot be converted to 'PyType'

Environment

  • Pydantic: 2

What Broke

Users experienced TypeErrors when defining models with `type[Self]` in Pydantic.

Why It Broke

The usage of `type[Self]` caused a TypeError due to improper handling in the schema validator

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 the model relies on unsupported type constructs.

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

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 the model relies on unsupported type constructs.

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.