Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #9901 · 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
@@ -83,6 +83,7 @@ is desired, you can switch to `left-to-right` mode and change the order of your * Add more robust custom validation examples by @ChrisPappalardo in [#9468](https://github.com/pydantic/pydantic/pull/9468) * Fix ignored `strict` specification for `StringConstraint(strict=False)` by @vbmendes in [#9476](https://github.com/pydantic/pydantic/pull/9476) +* **Breaking Change:** Use PEP 570 syntax by @Viicos in [#9479](https://github.com/pydantic/pydantic/pull/9479) * Use `Self` where possible by @Viicos in [#9479](https://github.com/pydantic/pydantic/pull/9479) * Do not alter `RootModel.model_construct` signature in the `mypy` plugin by @Viicos in [#9480](https://github.com/pydantic/pydantic/pull/9480)
repro.py
pydantic version: 2.7.4 pydantic-core version: 2.18.4 pydantic-core build: profile=release pgo=true install path: C:\Users\fraser\.virtualenvs\render-services-IYdnVPWc\Lib\site-packages\pydantic python version: 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] platform: Windows-10-10.0.22631-SP0 related packages: fastapi-0.111.0 mypy-1.8.0 typing_extensions-4.12.2 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==1.10.18\nWhen NOT to use: This fix should not be used if backward compatibility for __model_name is required.\n\n

Why This Fix Works in Production

  • Trigger: v2.8 create_model breaking change to api (__model_name->model_name), not in changelog
  • Mechanism: The change to create_model introduced a breaking change by altering the parameter name from __model_name to model_name
  • Why the fix works: Updated the changelog to reflect breaking changes regarding PEP 570, which affects the create_model function. (first fixed release: 1.10.18).
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 change to create_model introduced a breaking change by altering the parameter name from __model_name to model_name
  • Production symptom (often without a traceback): v2.8 create_model breaking change to api (__model_name->model_name), not in changelog

Proof / Evidence

Discussion

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

“The change added / to the signature, might I suggest also adding __model_name as a kw arg deprecated just for back compat - that should…”
@fraser-langton · 2024-07-16 · source
“> Do you have a use case where replacing create_model(__model_name=...) by create_model(...) isn't possible? Nup it's obviously a niche use case (but we had it)…”
@fraser-langton · 2024-07-16 · source
“@Viicos, thanks for opening the PR - I've approved. @fraser-langton, see https://github.com/pydantic/pydantic/issues/9810, which is a duplicate of this issue.”
@sydney-runkle · 2024-07-17 · source
“> The change added / to the signature, might I suggest also adding __model_name as a kw arg deprecated just for back compat - that…”
@Viicos · 2024-07-16 · source

Failure Signature (Search String)

  • v2.8 create_model breaking change to api (__model_name->model_name), not in changelog
  • Interesting to find this #1367 which originally changed model_name -> __model_name
Copy-friendly signature
signature.txt
Failure Signature ----------------- v2.8 create_model breaking change to api (__model_name->model_name), not in changelog Interesting to find this #1367 which originally changed model_name -> __model_name

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- v2.8 create_model breaking change to api (__model_name->model_name), not in changelog Interesting to find this #1367 which originally changed model_name -> __model_name

Minimal Reproduction

repro.py
pydantic version: 2.7.4 pydantic-core version: 2.18.4 pydantic-core build: profile=release pgo=true install path: C:\Users\fraser\.virtualenvs\render-services-IYdnVPWc\Lib\site-packages\pydantic python version: 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] platform: Windows-10-10.0.22631-SP0 related packages: fastapi-0.111.0 mypy-1.8.0 typing_extensions-4.12.2 commit: unknown

Environment

  • Pydantic: 2

What Broke

Users experienced API errors due to the breaking change in the create_model function.

Why It Broke

The change to create_model introduced a breaking change by altering the parameter name from __model_name to model_name

Fix Options (Details)

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

pip install pydantic==1.10.18

When NOT to use: This fix should not be used if backward compatibility for __model_name is required.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Fix reference: https://github.com/pydantic/pydantic/pull/9903

First fixed release: 1.10.18

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 for __model_name is required.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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

Related Issues

No related fixes found.

Sources

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