python
data_error
ai_generated
true
pydantic.errors.EnumError: value is not a valid enumeration member
ID: python/pydantic-enum-value-invalid
80%Fix Rate
86%Confidence
0Evidence
2024-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2.x | active | — | — | — |
Root Cause
A field typed as an Enum receives a value not defined in the enumeration.
generic中文
类型为枚举的字段接收到未在枚举中定义的值。
Workarounds
-
95% success
Use enum member: Color.RED
-
90% success
Add custom validator to map strings to enum
Dead Ends
Common approaches that don't work:
-
80% fail
Enum member type mismatch.
-
70% fail
Pydantic expects the value, not name.