{"record":{"id":"13f290e4ec307f9c","repo":"deepset-ai/haystack","slug":"error-while-unmarshalling-serialized-pipeline-data","errorCode":null,"errorMessage":"Error while unmarshalling serialized pipeline data. This is usually caused by malformed or invalid syntax in the serialized representation.","messagePattern":"Error while unmarshalling serialized pipeline data\\. This is usually caused by malformed or invalid syntax in the serialized representation\\.","errorType":"exception","errorClass":"DeserializationError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/base.py","lineNumber":352,"sourceCode":"        :param callbacks:\n            Callbacks to invoke during deserialization.\n        :param allowed_modules:\n            Additional module patterns whose classes may be imported during deserialization.\n            By default, only modules under `haystack`, `haystack_integrations`, `haystack_experimental`,\n            `builtins`, `typing`, and `collections` are trusted.\n        :param unsafe:\n            If `True`, bypass the deserialization allowlist entirely. Only use this when you fully\n            trust the source of the serialized data — any class in any importable module can be\n            instantiated.\n        :raises DeserializationError:\n            If an error occurs during deserialization.\n        :returns:\n            A `Pipeline` object.\n        \"\"\"\n        try:\n            deserialized_data = marshaller.unmarshal(data)\n        except Exception as e:\n            raise DeserializationError(\n                \"Error while unmarshalling serialized pipeline data. This is usually \"\n                \"caused by malformed or invalid syntax in the serialized representation.\"\n            ) from e\n\n        return cls.from_dict(deserialized_data, callbacks, allowed_modules=allowed_modules, unsafe=unsafe)\n\n    @classmethod\n    @mark_deserialization_internal\n    def load(\n        cls: type[T],\n        fp: TextIO,\n        marshaller: Marshaller = DEFAULT_MARSHALLER,\n        callbacks: DeserializationCallbacks | None = None,\n        *,\n        allowed_modules: list[str] | None = None,\n        unsafe: bool = False,\n    ) -> T:\n        \"\"\"","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/base.py#L334-L370","documentation":"Pipeline.loads() wraps any exception raised by the marshaller's unmarshal() step in a DeserializationError. This means the serialized string (e.g. YAML or JSON produced by dumps) could not be parsed back into a dictionary, typically because the text is malformed or is not a valid representation for the chosen marshaller.","triggerScenarios":"Calling Pipeline.loads(data) with a truncated, hand-edited, or syntactically invalid YAML/JSON string; calling loads with data serialized in a different format than the marshaller expects; passing bytes instead of str or empty/None data.","commonSituations":"Strings stored in a database or config file that were later corrupted; users editing exported YAML pipeline definitions by hand and breaking indentation; mixing formats after changing the default marshaller across Haystack versions.","solutions":["Validate/parse the string with an external YAML/JSON parser to find the syntax error before loading","Re-export the pipeline with Pipeline.dumps() instead of hand-editing serialized output","Ensure the same marshaller is used for dumps and loads (check Pipeline.dumps(marshaller=...) vs loads(marshaller=...))","Inspect the chained exception (__cause__) for the exact parser error and line"],"exampleFix":"// before\npipe = Pipeline.loads(edited_yaml)  # malformed after manual edit\n// after\nimport yaml\nyaml.safe_load(edited_yaml)  # locate syntax error first\npipe = Pipeline.loads(original_yaml)","handlingStrategy":"try-catch","validationCode":"import yaml\ndef is_loadable(data: str) -> bool:\n    try:\n        yaml.safe_load(data)\n        return bool(data and data.strip())\n    except yaml.YAMLError:\n        return False","typeGuard":"def is_serialized_pipeline(data: object) -> bool:\n    return isinstance(data, str) and len(data.strip()) > 0","tryCatchPattern":"from haystack.core.errors import DeserializationError\ntry:\n    pipe = Pipeline.loads(data)\nexcept DeserializationError as e:\n    logger.error(\"Bad pipeline data: %s\", e.__cause__)\n    raise","preventionTips":["Never hand-edit serialized pipelines; regenerate with dumps()","Keep dump and load marshalling symmetric","Validate YAML/JSON with a linter before loading","Log e.__cause__ to see the underlying parser error"],"tags":["python","serialization","pipeline"],"backgroundTag":"deserialization-failed","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}