Python enum _missing_ handler overwrites values on singleton for forward-compatible enums #5671
Labels
language/python
product/sdk-generator
Fern's SDK Generator that outputs client libraries in 7 languages
Issue Description
The configuration options for pydantic models allow users to set
forward_compatible_python_enums
as an option which will generate a_missing_
handler in enum definitions that will get called on unrecognized values.This missing handler returns the default instance of the enum value with a
_value_
attribute pointing to the raw, unrecognized original value.However, the
_UNKNOWN
instance of the enum is a singleton and the_value_
attribute on_UNKNOWN
is overwritten each time an unrecognized value is converted into an enum representation.This can lead to confusing behaviors like this:
The
_missing_
hook should at least alert the user that an unexpected value was passed in.Additional Context (Optional)
No response
The text was updated successfully, but these errors were encountered: