deepset-ai/haystack · error · PipelineValidationError
'{type(instance)}' doesn't seem to be a component. Is this c
Error message
'{type(instance)}' doesn't seem to be a component. Is this class decorated with @component? What it means
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.
Source
Thrown at haystack/core/pipeline/base.py:490
def _validate_component(self, name: str, instance: Component) -> bool:
"""Validate a component before adding it, returning whether it needs to be added."""
# Component names are unique
if name in self.graph.nodes:
if self.graph.nodes[name]["instance"] is instance:
return False
raise ValueError(f"A component named '{name}' already exists in this pipeline: choose another name.")
# Components can't be named `_debug`
if name == "_debug":
raise ValueError("'_debug' is a reserved name for debug output. Choose another name.")
# Component names can't have "."
if "." in name:
raise ValueError(f"{name} is an invalid component name, cannot contain '.' (dot) characters.")
# Component instances must be components
if not isinstance(instance, Component):
raise PipelineValidationError(
f"'{type(instance)}' doesn't seem to be a component. Is this class decorated with @component?"
)
if owning_pipeline := getattr(instance, "__haystack_added_to_pipeline__", None):
if owning_pipeline is self:
existing_name = self.get_component_name(instance)
msg = (
f"Component has already been added to this Pipeline under the name '{existing_name}'. "
"A component instance can only be added once."
)
else:
msg = (
"Component has already been added in another Pipeline. "
"Components can't be shared between Pipelines. Create a new instance instead."
)
raise PipelineError(msg)
return TrueView on GitHub (pinned to e318778c9b)
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
Example fix
// before
pipe.add_component("converter", TextConverter) # class, not instance
// after
pipe.add_component("converter", TextConverter()) Defensive patterns
Strategy: type-guard
Validate before calling
from haystack.core.component import Component
def is_component_instance(obj) -> bool:
return isinstance(obj, Component) and not isinstance(obj, type) Type guard
def is_component(obj: object) -> bool:
return isinstance(obj, Component) Try / catch
from haystack.core.errors import PipelineValidationError
try:
pipe.add_component(name, comp)
except PipelineValidationError as e:
logger.error("Not a component: %s", e)
raise Prevention
- Always instantiate: MyComp() not MyComp
- Decorate custom classes with @component
- Add a smoke test that adds every component in your registry to a Pipeline
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Component instance cannot be added to the pipeline more than
- Component has already been added to this Pipeline under the
- There is no component named '{name}' in the pipeline. The va
- Connecting a Component to itself is not supported.
- Component named {sender_component_name} not found in the pip
AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30).
Data as JSON: /api/errors/0e1372c56c1fc60b.
Report an issue: GitHub.