deepset-ai/haystack · error · DeserializationError
Value '{payload}' is not a valid member of Enum '{value_type
Error message
Value '{payload}' is not a valid member of Enum '{value_type}' What it means
Haystack raised DeserializationError because a payload string was looked up as an Enum member name via cls[payload] and no member with that name exists. The enum value stored in the serialized data does not correspond to any member of the enum class being restored.
Source
Thrown at haystack/utils/base_serialization.py:328
# try from_dict (e.g. Haystack dataclasses and Components)
if hasattr(cls, "from_dict") and callable(cls.from_dict):
return cls.from_dict(payload)
# handle pydantic models
if issubclass(cls, pydantic.BaseModel):
try:
return cls.model_validate(payload)
except Exception as e:
raise DeserializationError(
f"Failed to deserialize data '{payload}' into Pydantic model '{value_type}'"
) from e
# handle enum types
if issubclass(cls, Enum):
try:
return cls[payload]
except Exception as e:
raise DeserializationError(f"Value '{payload}' is not a valid member of Enum '{value_type}'") from e
# fallback: set attributes on a blank instance
deserialized_payload = {k: _deserialize_value(v) for k, v in payload.items()}
instance = cls.__new__(cls)
for attr_name, attr_value in deserialized_payload.items():
setattr(instance, attr_name, attr_value)
return instance
View on GitHub (pinned to e318778c9b)
Solutions
- Check the enum class for the exact member name and correct the serialized value
- If the enum was renamed, migrate old serialized pipelines to the new member name
- Store the member name (cls[key].name), not the value, when serializing custom enums
- Regenerate the pipeline serialization with the installed library version
Example fix
// before
{"retriever_type": "DENSE"} # no such member
// after
{"retriever_type": "dense"} # matches Enum member name Defensive patterns
Strategy: validation
Validate before calling
import enum
def validate_enum_member(enum_cls, name: str) -> bool:
return isinstance(name, str) and name in enum_cls.__members__ Type guard
def is_enum_member_name(enum_cls, value) -> bool:
return isinstance(value, str) and value in enum_cls.__members__ Try / catch
try:
pipeline = Pipeline.loads(yaml_str)
except DeserializationError as e:
logger.error("bad enum member in serialized data: %s", e)
raise Prevention
- Store enum member names (member.name), not values, when serializing custom enums
- After renaming enum members, migrate old pipeline files
- Search pipeline YAML for enum fields after each library upgrade
- Round-trip test dumps/loads in CI
When it happens
Trigger: Restoring a pipeline/component whose serialized init parameter is an Enum, where the payload string (e.g. "OLD_MEMBER") is not a member name of the current enum class.
Common situations: Enum member renamed or removed in a newer library version; hand-edited YAML/JSON with a typo in the member name; payload stores the enum's value instead of its name.
Related errors
- Refusing to deserialize an OutputAdapter with unsafe=True wh
- Refusing to deserialize an OutputAdapter with custom filters
- Unknown join mode '{string}'. Supported modes in AnswerJoine
- Missing 'type' in serialization data
- Failed to deserialize data '{payload}' into Pydantic model '
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/2816beace59cb9c3.
Report an issue: GitHub.