{"record":{"id":"d2ed39b2a899072e","repo":"deepset-ai/haystack","slug":"unknown-component-device-type-dict-type-in","errorCode":null,"errorMessage":"Unknown component device type '{dict['type']}' in serialized data","messagePattern":"Unknown component device type '(.+?)' in serialized data","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/utils/device.py","lineNumber":484,"sourceCode":"            return {\"type\": \"multiple\", \"device_map\": self._multiple_devices.to_dict()}\n        # Unreachable\n        raise AssertionError()\n\n    @classmethod\n    def from_dict(cls, dict: dict[str, Any]) -> \"ComponentDevice\":  # noqa:A002\n        \"\"\"\n        Create a component device representation from a JSON-serialized dictionary.\n\n        :param dict:\n            The serialized representation.\n        :returns:\n            The deserialized component device.\n        \"\"\"\n        if dict[\"type\"] == \"single\":\n            return cls.from_str(dict[\"device\"])\n        if dict[\"type\"] == \"multiple\":\n            return cls.from_multiple(DeviceMap.from_dict(dict[\"device_map\"]))\n        raise ValueError(f\"Unknown component device type '{dict['type']}' in serialized data\")\n\n\ndef _get_default_device() -> Device:\n    \"\"\"\n    Return the default device for Haystack.\n\n    Precedence:\n        GPU > XPU > MPS > CPU. If PyTorch is not installed, only CPU is available.\n\n    :returns:\n        The default device.\n    \"\"\"\n    try:\n        torch_import.check()\n\n        has_mps = (\n            hasattr(torch.backends, \"mps\")\n            and torch.backends.mps.is_available()","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/utils/device.py#L466-L502","documentation":"ComponentDevice.from_dict() deserializes a dict produced by to_dict(), which must have type set to 'single' or 'multiple'. Any other 'type' value means the serialized data is corrupt, hand-written incorrectly, or produced by an incompatible version.","triggerScenarios":"Calling ComponentDevice.from_dict({'type': 'gpu', 'device': 'cuda:0'}) or loading YAML/JSON where the device entry's 'type' key was edited or came from an older schema.","commonSituations":"Hand-editing serialized pipeline YAML; deserializing pipelines saved by a different Haystack version; typos like 'Single' or 'multi'.","solutions":["Set 'type' to 'single' with a 'device' string key, or 'multiple' with a 'device_map' dict.","Re-serialize the device/pipeline from a working ComponentDevice.to_dict() output.","Check for version mismatch between the Haystack that saved the data and the one loading it."],"exampleFix":"// before\nComponentDevice.from_dict({\"type\": \"gpu\", \"device\": \"cuda:0\"})\n// after\nComponentDevice.from_dict({\"type\": \"single\", \"device\": \"cuda:0\"})","handlingStrategy":"validation","validationCode":"def valid_device_dict(d):\n    return d.get(\"type\") in (\"single\", \"multiple\") and (\"device\" in d or \"device_map\" in d)","typeGuard":"def is_serialized_device(d: dict) -> bool:\n    return isinstance(d, dict) and d.get(\"type\") in {\"single\", \"multiple\"}","tryCatchPattern":"try:\n    dev = ComponentDevice.from_dict(d)\nexcept ValueError:\n    dev = ComponentDevice.from_str(d.get(\"device\", \"cpu\"))","preventionTips":["Only consume dicts produced by ComponentDevice.to_dict().","Don't hand-edit serialized pipeline YAML device entries.","Keep the Haystack version consistent between save and load."],"tags":["python","serialization","deserialization","haystack"],"backgroundTag":"unknown-enum-value","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}