deepset-ai/haystack · error · SerializationError
Component '{name}' of type '{type(component).__name__}' has
Error message
Component '{name}' of type '{type(component).__name__}' has an unsupported value of type '{type(v).__name__}' in the serialized data under key '{k}'. What it means
Like error 330 but raised from check_dict: a value found under a specific dict key is not a JSON-serializable type. The message names the offending key so you can locate the bad field quickly. It enforces that component serialization output is fully JSON-safe.
Source
Thrown at haystack/core/serialization.py:117
if not is_allowed_type(v):
raise SerializationError(
f"Component '{name}' of type '{type(component).__name__}' has an unsupported value "
f"of type '{type(v).__name__}' in the serialized data."
)
if isinstance(v, (list, set, tuple)):
check_iterable(v)
elif isinstance(v, dict):
check_dict(v)
def check_dict(d: dict[str, Any]) -> None:
if any(not isinstance(k, str) for k in d):
raise SerializationError(
f"Component '{name}' of type '{type(component).__name__}' has a non-string key in the serialized data."
)
for k, v in d.items():
if not is_allowed_type(v):
raise SerializationError(
f"Component '{name}' of type '{type(component).__name__}' has an unsupported value "
f"of type '{type(v).__name__}' in the serialized data under key '{k}'."
)
if isinstance(v, (list, set, tuple)):
check_iterable(v)
elif isinstance(v, dict):
check_dict(v)
check_dict(data)
def generate_qualified_class_name(cls: type[object]) -> str:
"""
Generates a qualified class name for a class.
:param cls:
The class whose qualified name is to be generated.
:returns:View on GitHub (pinned to e318778c9b)
Solutions
- Open the component's to_dict() and convert the value under the reported key to a primitive or a typed dict with 'type'.
- Add matching from_dict() logic to reconstruct the original object.
- Convert the object to a supported type before passing it to the component.
- If the value comes from a third-party component, report/upgrade the component.
Example fix
// before
{"init_parameters": {"filters": {"created": some_datetime}}}
// after
{"init_parameters": {"filters": {"created": some_datetime.isoformat()}}} Defensive patterns
Strategy: validation
Validate before calling
import json
def ensure_json_safe(component_dict) -> bool:
try:
json.dumps(component_dict)
return True
except (TypeError, ValueError):
return False Type guard
def is_primitive(v) -> bool:
return v is None or isinstance(v, (str, int, float, bool)) or (isinstance(v, (list, dict, set, tuple)) ) Try / catch
from haystack.core.errors import SerializationError
try:
yaml_str = pipeline.dumps()
except SerializationError as e:
# message names the offending key 'k'; fix that field in the component's to_dict
print(e) Prevention
- Sanity-check to_dict output with json.dumps in unit tests
- Convert datetime/UUID/bytes to strings at serialization boundaries
- Keep custom object serialization in dedicated to_dict/from_dict pairs with a 'type' discriminator
When it happens
Trigger: pipeline.dumps()/to_dict() where an init parameter under key 'k' holds an unsupported object (custom class instance, datetime, bytes, numpy value, set-of-custom-objects).
Common situations: Custom components with unconverted init parameters; a nested dict parameter containing arbitrary Python objects; third-party component upgrades introducing new parameter types.
Related errors
- Component '{name}' of type '{type(component).__name__}' has
- Component '{name}' of type '{type(component).__name__}' has
- Serialization of instance methods is not supported.
- Serialization of lambdas is not supported.
- Serialization of nested functions is not supported.
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/a35e4bba22193904.
Report an issue: GitHub.