{"record":{"id":"0e1372c56c1fc60b","repo":"deepset-ai/haystack","slug":"type-instance-doesn-t-seem-to-be-a-component","errorCode":null,"errorMessage":"'{type(instance)}' doesn't seem to be a component. Is this class decorated with @component?","messagePattern":"'(.+?)' doesn't seem to be a component\\. Is this class decorated with @component\\?","errorType":"exception","errorClass":"PipelineValidationError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/base.py","lineNumber":490,"sourceCode":"    def _validate_component(self, name: str, instance: Component) -> bool:\n        \"\"\"Validate a component before adding it, returning whether it needs to be added.\"\"\"\n        # Component names are unique\n        if name in self.graph.nodes:\n            if self.graph.nodes[name][\"instance\"] is instance:\n                return False\n            raise ValueError(f\"A component named '{name}' already exists in this pipeline: choose another name.\")\n\n        # Components can't be named `_debug`\n        if name == \"_debug\":\n            raise ValueError(\"'_debug' is a reserved name for debug output. Choose another name.\")\n\n        # Component names can't have \".\"\n        if \".\" in name:\n            raise ValueError(f\"{name} is an invalid component name, cannot contain '.' (dot) characters.\")\n\n        # Component instances must be components\n        if not isinstance(instance, Component):\n            raise PipelineValidationError(\n                f\"'{type(instance)}' doesn't seem to be a component. Is this class decorated with @component?\"\n            )\n\n        if owning_pipeline := getattr(instance, \"__haystack_added_to_pipeline__\", None):\n            if owning_pipeline is self:\n                existing_name = self.get_component_name(instance)\n                msg = (\n                    f\"Component has already been added to this Pipeline under the name '{existing_name}'. \"\n                    \"A component instance can only be added once.\"\n                )\n            else:\n                msg = (\n                    \"Component has already been added in another Pipeline. \"\n                    \"Components can't be shared between Pipelines. Create a new instance instead.\"\n                )\n            raise PipelineError(msg)\n\n        return True","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/base.py#L472-L508","documentation":"Pipeline components must be instances of classes decorated with @component (i.e. implement the Component protocol). If the object passed to add_component is not such an instance, PipelineValidationError is raised so the mistake is caught at wiring time instead of at run time.","triggerScenarios":"Passing a class instead of an instance: pipe.add_component(\"c\", MyComp) without parentheses; passing an undecorated class instance; passing None or a dict of components by mistake.","commonSituations":"Forgetting to instantiate the component class; forgetting the @component decorator on a custom component after a refactor; swapping in a mock or plain object in tests.","solutions":["Instantiate the class: pipe.add_component(\"c\", MyComp())","Decorate the custom class with @component and implement run()","Verify the object's type has the __haystack_supports_can_run__ / Component protocol before adding"],"exampleFix":"// before\npipe.add_component(\"converter\", TextConverter)  # class, not instance\n// after\npipe.add_component(\"converter\", TextConverter())","handlingStrategy":"type-guard","validationCode":"from haystack.core.component import Component\n\ndef is_component_instance(obj) -> bool:\n    return isinstance(obj, Component) and not isinstance(obj, type)","typeGuard":"def is_component(obj: object) -> bool:\n    return isinstance(obj, Component)","tryCatchPattern":"from haystack.core.errors import PipelineValidationError\ntry:\n    pipe.add_component(name, comp)\nexcept PipelineValidationError as e:\n    logger.error(\"Not a component: %s\", e)\n    raise","preventionTips":["Always instantiate: MyComp() not MyComp","Decorate custom classes with @component","Add a smoke test that adds every component in your registry to a Pipeline"],"tags":["python","pipeline","api-misuse"],"backgroundTag":"invalid-component-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}