The Fix
pip install pydantic==2.6.4
Based on closed pydantic/pydantic issue #8858 · 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%.
@@ -81,8 +81,6 @@ def get_json_schema(_, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
return core_schema.is_instance_schema(enum_type, metadata={'pydantic_js_functions': [get_json_schema]})
- use_enum_values = config.get('use_enum_values', False)
-
if len(cases) == 1:
from pydantic import BaseModel, __version__ as pydantic_version
from enum import Enum
class MyEnum(str, Enum):
A = 'a'
class MyModel(BaseModel, use_enum_values=True):
my_enum: MyEnum
class OtherModel(BaseModel):
also_my_enum: MyEnum
class Model(BaseModel):
my_model: MyModel
other_model: OtherModel
data = {'my_model': {'my_enum': 'a'}, 'other_model': {'also_my_enum': 'a'}}
print(f'{pydantic_version=}')
# pydantic_version='2.6.1'
print(Model.parse_obj(data))
# my_model=MyModel(my_enum=<MyEnum.A: 'a'>) other_model=OtherModel(also_my_enum=<MyEnum.A: 'a'>)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==2.6.4\nWhen NOT to use: Do not apply this fix if all models using the enum should maintain their original behavior.\n\n
Why This Fix Works in Production
- Trigger: If two separate models with different `use_enum_values` settings both have fields with the same enum, pydantic v2 doesn't use that enum's values in either…
- Mechanism: The use_enum_values setting was not respected when multiple models used the same enum with different settings
- Why the fix works: Fixes a regression where the use_enum_values setting in Pydantic v2 was not respected when multiple models used the same enum with different settings. (first fixed release: 2.6.4).
- 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 use_enum_values setting was not respected when multiple models used the same enum with different settings
- Production symptom (often without a traceback): If two separate models with different `use_enum_values` settings both have fields with the same enum, pydantic v2 doesn't use that enum's values in either model.
Proof / Evidence
- GitHub issue: #8858
- Fix PR: https://github.com/pydantic/pydantic/pull/8920
- First fixed release: 2.6.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.55
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: pydantic
- Fixed: 2.6.4
- Mode: fixed_only
- Outcome: ok
Logs
pydantic_version='2.6.4'
my_model=MyModel(my_enum=<MyEnum.A: 'a'>) other_model=OtherModel(also_my_enum=<MyEnum.A: 'a'>)
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@sydney-runkle I can try and look into this if it's still available 😄”
“Ah, @dmontagu came up with a fix: https://github.com/pydantic/pydantic/pull/8920”
“@vaultah, Yep, looks like a bug. Thanks for reporting the regression. You're welcome to submit a PR with a fix, if you'd like. I'll add…”
“@sydney-runkle Awesome! Let me know if there's anything I can do to help out”
Failure Signature (Search String)
- If two separate models with different `use_enum_values` settings both have fields with the same enum, pydantic v2 doesn't use that enum's values in either model.
- This is a regression from pydantic v1.
Copy-friendly signature
Failure Signature
-----------------
If two separate models with different `use_enum_values` settings both have fields with the same enum, pydantic v2 doesn't use that enum's values in either model.
This is a regression from pydantic v1.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
If two separate models with different `use_enum_values` settings both have fields with the same enum, pydantic v2 doesn't use that enum's values in either model.
This is a regression from pydantic v1.
Minimal Reproduction
from pydantic import BaseModel, __version__ as pydantic_version
from enum import Enum
class MyEnum(str, Enum):
A = 'a'
class MyModel(BaseModel, use_enum_values=True):
my_enum: MyEnum
class OtherModel(BaseModel):
also_my_enum: MyEnum
class Model(BaseModel):
my_model: MyModel
other_model: OtherModel
data = {'my_model': {'my_enum': 'a'}, 'other_model': {'also_my_enum': 'a'}}
print(f'{pydantic_version=}')
# pydantic_version='2.6.1'
print(Model.parse_obj(data))
# my_model=MyModel(my_enum=<MyEnum.A: 'a'>) other_model=OtherModel(also_my_enum=<MyEnum.A: 'a'>)
Environment
- Pydantic: 2
What Broke
Models failed to parse enum values correctly, leading to unexpected types in the output.
Why It Broke
The use_enum_values setting was not respected when multiple models used the same enum with different settings
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.6.4
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/8920
First fixed release: 2.6.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if all models using the enum should maintain their original behavior.
Verify Fix
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
| Version | Status |
|---|---|
| 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.