{"record":{"id":"3f28a2304a620de6","repo":"deepset-ai/haystack","slug":"the-value-of-key-is-not-a-dictionary","errorCode":null,"errorMessage":"The value of '{key}' is not a dictionary","messagePattern":"The value of '(.+?)' is not a dictionary","errorType":"exception","errorClass":"DeserializationError","httpStatus":null,"severity":"error","filePath":"haystack/utils/deserialization.py","lineNumber":46,"sourceCode":"    \"\"\"\n    Deserialize a Component in a dictionary inplace.\n\n    :param data:\n        The dictionary with the serialized data.\n    :param key:\n        The key in the dictionary where the Component is stored. Default is \"chat_generator\".\n\n    :raises DeserializationError:\n        If the key is missing in the serialized data, the value is not a dictionary,\n        the type key is missing, the class cannot be imported, or the class lacks a 'from_dict' method.\n    \"\"\"\n    if key not in data:\n        raise DeserializationError(f\"Missing '{key}' in serialization data\")\n\n    serialized_component = data[key]\n\n    if not isinstance(serialized_component, dict):\n        raise DeserializationError(f\"The value of '{key}' is not a dictionary\")\n\n    if \"type\" not in serialized_component:\n        raise DeserializationError(f\"Missing 'type' in {key} serialization data\")\n\n    try:\n        component_class = import_class_by_name(serialized_component[\"type\"])\n    except ImportError as e:\n        raise DeserializationError(f\"Class '{serialized_component['type']}' not correctly imported\") from e\n\n    data[key] = component_from_dict(cls=component_class, data=serialized_component, name=key)\n","sourceCodeStart":28,"sourceCodeEnd":57,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/utils/deserialization.py#L28-L57","documentation":"deserialize_component_inplace found the key but its value is not a dictionary, so it raises DeserializationError. Component serialization data must be a dict containing at least a 'type' field naming the importable class path.","triggerScenarios":"Passing data where data[key] is a string, list, or None instead of a dict of component definitions, e.g. components: \"foo\" or components: [a, b] in the pipeline dict/YAML.","commonSituations":"YAML where the components value is indented incorrectly and parses as a string or list; loading a hand-edited pipeline; passing the wrong variable to from_dict.","solutions":["Ensure the value under the key is a mapping of component-name -> {type, init_parameters}","Fix YAML indentation so components parse as a dict","Regenerate the file with pipeline.dumps()","Validate the input structure before calling from_dict (isinstance(data[key], dict))"],"exampleFix":"// before\ncomponents:\n  - retriever\n// after\ncomponents:\n  retriever:\n    type: haystack.components.retrievers.in_memory.InMemoryEmbeddingRetriever\n    init_parameters: {}","handlingStrategy":"validation","validationCode":"def validate_components(data):\n    comps = data.get(\"components\")\n    if not isinstance(comps, dict):\n        raise ValueError(\"'components' must be a dict of name -> {type, init_parameters}\")\n    return comps","typeGuard":"def are_valid_components(data) -> bool:\n    comps = data.get(\"components\") if isinstance(data, dict) else None\n    return isinstance(comps, dict) and all(\n        isinstance(v, dict) and \"type\" in v for v in comps.values()\n    )","tryCatchPattern":"try:\n    pipeline = Pipeline.loads(yaml_str)\nexcept DeserializationError as e:\n    if \"not a dictionary\" in str(e):\n        logger.error(\"components section malformed: %s\", e)\n    raise","preventionTips":["Keep 'components' as a mapping, never a list or string, in pipeline YAML","Fix indentation so YAML parses components as a dict","Validate structure with a schema check before from_dict","Regenerate files with pipeline.dumps() after manual edits"],"tags":["python","deserialization","pipeline","haystack"],"backgroundTag":"missing-key-in-serialized-data","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}