{"record":{"id":"40505bb6b0d7e049","repo":"deepset-ai/haystack","slug":"e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"exception","errorClass":"DeserializationError","httpStatus":null,"severity":"error","filePath":"haystack/utils/type_serialization.py","lineNumber":269,"sourceCode":"        # arguments.\n        if main_type is typing.Literal:\n            return typing.Literal[ast.literal_eval(f\"({generics_str},)\")]\n\n        generic_args = [_deserialize_type_arg(arg) for arg in _parse_generic_args(generics_str)]\n\n        # Reconstruct\n        try:\n            return main_type[tuple(generic_args) if len(generic_args) > 1 else generic_args[0]]\n        except (TypeError, AttributeError) as e:\n            raise DeserializationError(f\"Could not apply arguments {generic_args} to type {main_type}\") from e\n\n    # Handle non-generic types\n    # First, check if there's a module prefix\n    if \".\" in type_str:\n        try:\n            return _import_class_by_name(type_str)\n        except ImportError as e:\n            raise DeserializationError(str(e)) from e\n\n    # No module prefix, check builtins and typing.\n    # (None / NoneType / Ellipsis are handled at the top of this function, before they can reach the\n    # builtin type gate below which would refuse them for not being types.)\n    if hasattr(builtins, type_str):\n        resolved = getattr(builtins, type_str)\n        # This bare-name path never consults the allowlist. A type annotation must resolve to an\n        # actual type, so builtin functions like `eval`/`exec` are rejected while types pass.\n        _check_builtin_is_type(resolved, type_str)\n        return resolved\n\n    # Then check typing\n    if hasattr(typing, type_str):\n        return getattr(typing, type_str)\n\n    raise DeserializationError(f\"Could not deserialize type: {type_str}\")\n\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/utils/type_serialization.py#L251-L287","documentation":"When a type string contains a dot, deserialize_type() tries to import it with _import_class_by_name(); an ImportError there is re-raised as DeserializationError(str(e)) with this message. It means the module or class path stored in the serialized data could not be imported. This guards against loading pipelines that reference unavailable or blocked code.","triggerScenarios":"deserialize_type('my.module.MyClass') where my.module is not installed, renamed, or the class attribute no longer exists; loading a pipeline YAML created in another project/environment.","commonSituations":"Missing optional dependency in the target environment; package refactor renamed module paths between versions; pickled/serialized component schema shared across codebases.","solutions":["Install or fix the import path for the module referenced in the type string (pip install the package)","Check for renames: update the serialized type string to the current module/class path","If the class is intentionally blocked (haystack internal), use the public replacement type","Reproduce with `from my.module import MyClass` to see the real import error"],"exampleFix":"// before\n{\"type\": \"haystack.testing.factory.TestComponent\"}\n// after\n{\"type\": \"my_app.components.TestComponent\"}  # valid importable path","handlingStrategy":"try-catch","validationCode":"import importlib\ndef can_import(dotted):\n    mod, _, attr = dotted.rpartition(\".\")\n    try:\n        return hasattr(importlib.import_module(mod), attr)\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"from haystack.utils import DeserializationError\ntry:\n    t = deserialize_type(type_str)\nexcept DeserializationError as e:\n    # str(e) is the underlying ImportError message\n    raise RuntimeError(f\"Cannot load pipeline, missing component: {e}\") from e","preventionTips":["Pin and install all component dependencies in the target environment","Use fully qualified, stable public class paths in serialized data","Re-serialize pipelines after upgrading haystack versions"],"tags":["python","deserialization","import-error","haystack"],"backgroundTag":"module-import-failed","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}