deepset-ai/haystack · error · TypeError
Error loading pipeline from YAML - Ensure that all pipeline
Error message
Error loading pipeline from YAML - Ensure that all pipeline components only serialize basic Python types
What it means
YamlMarshaller.unmarshal loads YAML back into a dictionary; the YAML must only use constructor tags for basic types. If the YAML contains unknown or unsafe python-specific tags (from another marshaller/version or hand-editing), yaml raises ConstructorError, re-raised as a TypeError with guidance about basic Python types.
Source
Thrown at haystack/marshal/yaml.py:42
YamlLoader.add_constructor("tag:yaml.org,2002:python/tuple", YamlLoader.construct_python_tuple)
class YamlMarshaller:
def marshal(self, dict_: dict[str, Any]) -> str:
"""Return a YAML representation of the given dictionary."""
try:
return yaml.dump(dict_, Dumper=YamlDumper)
except yaml.representer.RepresenterError as e:
raise TypeError(
"Error dumping pipeline to YAML - Ensure that all pipeline components only serialize basic Python types"
) from e
def unmarshal(self, data_: str | bytes | bytearray) -> dict[str, Any]:
"""Return a dictionary from the given YAML data."""
try:
return yaml.load(data_, Loader=YamlLoader)
except yaml.constructor.ConstructorError as e:
raise TypeError(
"Error loading pipeline from YAML - Ensure that all pipeline "
"components only serialize basic Python types"
) from e
View on GitHub (pinned to e318778c9b)
Solutions
- Regenerate the YAML with the same haystack pipeline's dumps/marshal so it uses supported tags
- Remove or replace unsupported tags in the YAML with plain basic-type values
- Confirm you are loading YAML (not JSON/marshalled bytes from another marshaller) with the matching loader
Example fix
// before
components:
cleaner: !!python/object:pipeline.Cleaner {x: 1} # unsupported tag
// after
components:
cleaner:
type: pipeline.Cleaner
init_parameters: {x: 1} Defensive patterns
Strategy: try-catch
Validate before calling
import yaml
class NoUnknownTags(yaml.SafeLoader): pass
def check_yaml_tags(data):
list(yaml.compose(data, Loader=NoUnknownTags)) # raises on unsupported tags Try / catch
try:
d = marshaller.unmarshal(data)
except TypeError as e:
if "loading pipeline from YAML" in str(e):
d = marshaller.unmarshal(regenerate_yaml(data)) # re-dump with supported tags
else:
raise Prevention
- Only load YAML produced by the same haystack version's dumps/marshal
- Never paste YAML containing !!python/ or custom tags into pipeline files
- Validate YAML round-trips after manual edits
When it happens
Trigger: Calling unmarshal (or pipeline loads) on YAML containing tags YamlLoader cannot construct — e.g. `!!python/object` tags, custom tags emitted by other tools, or corrupted/hand-edited pipeline YAML.
Common situations: Loading YAML produced by a different haystack version or a JSON/YAML dump with custom tags; manually edited pipeline files with stray tags; cross-framework marshalled content pasted into haystack YAML.
Related errors
- Error dumping pipeline to YAML - Ensure that all pipeline co
- Missing 'type' in component '{name}'
- Missing sender in connection: {connection}
- Missing receiver in connection: {connection}
- Error while unmarshalling serialized pipeline data. This is
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/b283c3f552794ed7.
Report an issue: GitHub.