Jump to solution
Verify

The Fix

The limitation of using both `__config__` and `__base__` together in `create_model()` was removed, allowing for more flexible model creation.

Based on closed pydantic/pydantic issue #11806 · 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
@@ -631,23 +631,6 @@ except PydanticUserError as exc_info: The fields definition syntax can be found in the [dynamic model creation](../concepts/models.md#dynamic-model-creation) documentation. - -## `create_model` config base {#create-model-config-base} -
repro.py
pydantic version: 2.10.0 pydantic-core version: 2.27.0 pydantic-core build: profile=release pgo=false install path: C:\Users\MG280560\AppData\Roaming\mamba\envs\fastapi\Lib\site-packages\pydantic python version: 3.11.11 | packaged by conda-forge | (main, Dec 5 2024, 14:06:23) [MSC v.1942 64 bit (AMD64)] platform: Windows-10-10.0.19045-SP0 related packages: fastapi-0.115.6 pydantic-settings-2.7.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 — Apply the official fix\nThe limitation of using both `__config__` and `__base__` together in `create_model()` was removed, allowing for more flexible model creation.\nWhen NOT to use: This fix is not applicable if you require both `__config__` and `__base__` to be used together.\n\n

Why This Fix Works in Production

  • Trigger: pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name.
  • Mechanism: The limitation of using both `__config__` and `__base__` together in `create_model()` was enforced incorrectly
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 limitation of using both `__config__` and `__base__` together in `create_model()` was enforced incorrectly
  • Surfaces as: pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name.

Proof / Evidence

Discussion

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

“You need to use the documented __config__ argument for this. Providing model_config used to accidentally work, but this was only coincidental.”
@Viicos · 2025-04-29 · source
“Mmmhhh, using both __base__ and __config__ in create_model is not possible, raising this Exception:”
@mgo-cea · 2025-04-29 · source
“This limitation was removed in https://github.com/pydantic/pydantic/pull/11714, and I'll backport it in the next patch release (should be today).”
@Viicos · 2025-04-29 · source
“OK, excellent. Thank you very much for the swift reaction!”
@mgo-cea · 2025-04-29 · source

Failure Signature (Search String)

  • pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name.

Error Message

Stack trace
error.txt
Error Message ------------- pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name.
Stack trace
error.txt
Error Message ------------- pydantic.errors.PydanticUserError: to avoid confusion `__config__` and `__base__` cannot be used together

Minimal Reproduction

repro.py
pydantic version: 2.10.0 pydantic-core version: 2.27.0 pydantic-core build: profile=release pgo=false install path: C:\Users\MG280560\AppData\Roaming\mamba\envs\fastapi\Lib\site-packages\pydantic python version: 3.11.11 | packaged by conda-forge | (main, Dec 5 2024, 14:06:23) [MSC v.1942 64 bit (AMD64)] platform: Windows-10-10.0.19045-SP0 related packages: fastapi-0.115.6 pydantic-settings-2.7.0 typing_extensions-4.12.2 commit: unknown

Environment

  • Pydantic: 2

Why It Broke

The limitation of using both `__config__` and `__base__` together in `create_model()` was enforced incorrectly

Fix Options (Details)

Option A — Apply the official fix

The limitation of using both `__config__` and `__base__` together in `create_model()` was removed, allowing for more flexible model creation.

When NOT to use: This fix is not applicable if you require both `__config__` and `__base__` to be used together.

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

Last verified: 2026-02-11. 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 you require both `__config__` and `__base__` to be used together.

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.

Related Issues

No related fixes found.

Sources

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