Jump to solution
Verify

The Fix

pip install pydantic==2.6.4

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

Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.

Jump to Verify Open PR/Commit
@@ -2176,9 +2176,14 @@ def model_json_schema( The generated JSON Schema. """ + from .main import BaseModel + schema_generator_instance = schema_generator(by_alias=by_alias, ref_template=ref_template)
repro.py
pydantic version: 2.6.3 pydantic-core version: 2.16.3 pydantic-core build: profile=release pgo=true install path: C:\...\venv\Lib\site-packages\pydantic python version: 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] platform: Windows-10-10.0.19045-SP0 related packages: typing_extensions-4.9.0 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.6.4\nWhen NOT to use: This fix is not applicable if using BaseModel directly without subclassing.\n\n

Why This Fix Works in Production

  • Trigger: The JSON schema for the BaseModel class
  • Mechanism: The BaseModel class was incorrectly used, leading to an AssertionError
  • Why the fix works: Provides a more helpful error message for incorrect usage of the `model_json_schema` method in the BaseModel class. (first fixed release: 2.6.4).
Production impact:
  • If left unfixed, retries/timeouts can trigger duplicate external side-effects (double charges, duplicate emails, repeated writes).

Why This Breaks in Prod

  • The BaseModel class was incorrectly used, leading to an AssertionError
  • Production symptom (often without a traceback): The JSON schema for the BaseModel class

Proof / Evidence

Discussion

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

“This is a duplicate of https://github.com/pydantic/pydantic/issues/8896, which was fixed in https://github.com/pydantic/pydantic/pull/8928.”
@Viicos · 2024-03-12 · confirmation · source

Failure Signature (Search String)

  • The JSON schema for the BaseModel class
  • On running the code in the example below I receive "AssertionError: this is a bug! please report it"
Copy-friendly signature
signature.txt
Failure Signature ----------------- The JSON schema for the BaseModel class On running the code in the example below I receive "AssertionError: this is a bug! please report it"

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- The JSON schema for the BaseModel class On running the code in the example below I receive "AssertionError: this is a bug! please report it"

Minimal Reproduction

repro.py
pydantic version: 2.6.3 pydantic-core version: 2.16.3 pydantic-core build: profile=release pgo=true install path: C:\...\venv\Lib\site-packages\pydantic python version: 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] platform: Windows-10-10.0.19045-SP0 related packages: typing_extensions-4.9.0 commit: unknown

Environment

  • Pydantic: 2

What Broke

Users encountered an AssertionError when calling model_json_schema on BaseModel.

Why It Broke

The BaseModel class was incorrectly used, leading to an AssertionError

Fix Options (Details)

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

pip install pydantic==2.6.4

When NOT to use: This fix is not applicable if using BaseModel directly without subclassing.

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

First fixed release: 2.6.4

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 is not applicable if using BaseModel directly without subclassing.

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

Related Issues

No related fixes found.

Sources

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