{"record":{"id":"e5cfa9905193059a","repo":"deepset-ai/haystack","slug":"successfully-imported-module-module-but-couldn","errorCode":null,"errorMessage":"Successfully imported module '{module}' but couldn't find '{component_type}' in the component registry.\nThe component might be registered under a different path. Here are the registered components:\n {list(component.registry.keys())}\n","messagePattern":"Successfully imported module '(.+?)' but couldn't find '(.+?)' in the component registry\\.\nThe component might be registered under a different path\\. Here are the registered components:\n (.+?)\n","errorType":"exception","errorClass":"PipelineError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/base.py","lineNumber":249,"sourceCode":"                # Reuse an instance\n                instance = components_to_reuse[name]\n            else:\n                if \"type\" not in component_data:\n                    raise PipelineError(f\"Missing 'type' in component '{name}'\")\n\n                component_type = component_data[\"type\"]\n                if isinstance(component_type, str) and \".\" in component_type:\n                    _check_module_allowed(component_type.rsplit(\".\", 1)[0])\n\n                if component_type not in component.registry:\n                    try:\n                        # Import the module first...\n                        module, _ = component_type.rsplit(\".\", 1)\n                        logger.debug(\"Trying to import module {module_name}\", module_name=module)\n                        type_serialization.thread_safe_import(module)\n                        # ...then try again\n                        if component_type not in component.registry:\n                            raise PipelineError(  # noqa: TRY301\n                                f\"Successfully imported module '{module}' but couldn't find \"\n                                f\"'{component_type}' in the component registry.\\n\"\n                                f\"The component might be registered under a different path. \"\n                                f\"Here are the registered components:\\n {list(component.registry.keys())}\\n\"\n                            )\n                    except (ImportError, PipelineError, ValueError) as e:\n                        raise PipelineError(\n                            f\"Component '{component_type}' (name: '{name}') not imported. Please \"\n                            f\"check that the package is installed and the component path is correct.\"\n                        ) from e\n\n                # Create a new one\n                component_class = component.registry[component_type]\n\n                try:\n                    instance = component_from_dict(component_class, component_data, name, callbacks)\n                except Exception as e:\n                    # Convert to JSON with indentation, truncate if too long","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/base.py#L231-L267","documentation":"When a serialized component's 'type' is a dotted path not yet in the registry, Haystack imports the module and re-checks the registry. If the class is still absent, it raises PipelineError listing all registered components, meaning the path doesn't match any registered component key.","triggerScenarios":"from_dict on a pipeline whose component 'type' points to a class that imports fine but never registered itself — wrong class name, custom component file imported but @component never applied, or the registry key differs from the string used.","commonSituations":"Renaming a custom component class but keeping the old type string in YAML; using a fully-qualified path to a class without the @component decorator; extra haystack-core-haystack duplicate installs where one copy registers but the other is imported.","solutions":["Fix the 'type' string in the pipeline definition to the exact registry key of the component","Ensure the component class is decorated with @component so it registers on import","Run component.registry keys (printed in the error) and copy the exact path","Avoid duplicate haystack installs in the environment (pip check / single venv)"],"exampleFix":"// before\n# type: my_custom_components.Ranker  (class has no @component)\n\n// after\n@component\nclass Ranker:  # in module my_custom_components\n    ...\n# and in yaml: type: my_custom_components.Ranker","handlingStrategy":"validation","validationCode":"import haystack.core.component as hc\n\ndef check_types_registered(data: dict) -> list[str]:\n    missing = []\n    for name, comp in data.get(\"components\", {}).items():\n        t = comp.get(\"type\")\n        if t and t not in hc.component.registry:\n            try:\n                module, _ = t.rsplit(\".\", 1)\n                __import__(module)\n            except Exception as e:\n                missing.append(f\"{name}: cannot import {t}: {e}\")\n    return missing","typeGuard":"def is_registered(component_type: str) -> bool:\n    from haystack.core.component import component\n    return component_type in component.registry","tryCatchPattern":"try:\n    pipe = Pipeline.from_dict(data)\nexcept PipelineError as e:\n    if \"couldn't find\" in str(e):\n        logging.error(\"Fix the component path or register the component: %s\", e)","preventionTips":["Decorate custom classes with @component so they self-register on import","Import the module containing custom components before from_dict","Compare 'type' strings against the registry keys printed in the error","Keep a single haystack install per environment"],"tags":["serialization","import","registry","pipeline","haystack"],"backgroundTag":"component-not-registered","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}