The Fix
pip install pydantic==2.7.2
Based on closed pydantic/pydantic issue #9397 · 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%.
@@ -1117,6 +1117,25 @@ except PydanticUserError as exc_info:
```
+
+## [`with_config`][pydantic.config.with_config] is used on a `BaseModel` subclass {#with-config-on-model}
+
Option A — Upgrade to fixed release\npip install pydantic==2.7.2\nWhen NOT to use: This fix is not applicable if `with_config` is intended for non-Pydantic models.\n\n
Why This Fix Works in Production
- Trigger: From https://github.com/pydantic/pydantic/issues/9389#issuecomment-2095723828, I think using `with_config` with a Pydantic model should be disallowed and…
- Mechanism: Using `with_config` on a Pydantic model leads to runtime errors
- Why the fix works: Disallow usage of `with_config` on a Pydantic model, resulting in a runtime error. (first fixed release: 2.7.2).
- 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
- Using `with_config` on a Pydantic model leads to runtime errors
- Production symptom (often without a traceback): From https://github.com/pydantic/pydantic/issues/9389#issuecomment-2095723828, I think using `with_config` with a Pydantic model should be disallowed and result in a runtime error.
Proof / Evidence
- GitHub issue: #9397
- Fix PR: https://github.com/pydantic/pydantic/pull/9398
- First fixed release: 2.7.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.70
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [X] I have searched Google & GitHub for similar requests and couldn't find anything - [X] I have read and followed the docs and still think this feature is missing ### Description From https://github.com/pydantic/pydant”
Failure Signature (Search String)
- From https://github.com/pydantic/pydantic/issues/9389#issuecomment-2095723828, I think using `with_config` with a Pydantic model should be disallowed and result in a runtime error.
- - [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
Copy-friendly signature
Failure Signature
-----------------
From https://github.com/pydantic/pydantic/issues/9389#issuecomment-2095723828, I think using `with_config` with a Pydantic model should be disallowed and result in a runtime error.
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
Error Message
Signature-only (no traceback captured)
Error Message
-------------
From https://github.com/pydantic/pydantic/issues/9389#issuecomment-2095723828, I think using `with_config` with a Pydantic model should be disallowed and result in a runtime error.
- [ ] [Compatibility between releases](https://docs.pydantic.dev/changelog/)
What Broke
Runtime errors occur when `with_config` is incorrectly applied to Pydantic models.
Why It Broke
Using `with_config` on a Pydantic model leads to runtime errors
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.7.2
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/9398
First fixed release: 2.7.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if `with_config` is intended for non-Pydantic models.
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
| Version | Status |
|---|---|
| 2.7.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.