deepset-ai/haystack · error · ValueError

Component named {name} not found in the pipeline.

Error message

Component named {name} not found in the pipeline.

What it means

Pipeline.get_component() raises ValueError when no node with the given name exists in the pipeline graph; the underlying dict/graph KeyError is re-raised as ValueError. Called indirectly by remove_component(), which shares this lookup.

Source

Thrown at haystack/core/pipeline/base.py:832

        return self

    def get_component(self, name: str) -> Component:
        """
        Get the component with the specified name from the pipeline.

        :param name:
            The name of the component.
        :returns:
            The instance of that component.

        :raises ValueError:
            If a component with that name is not present in the pipeline.
        """
        try:
            return self.graph.nodes[name]["instance"]
        except KeyError as exc:
            raise ValueError(f"Component named {name} not found in the pipeline.") from exc

    def get_component_name(self, instance: Component) -> str:
        """
        Returns the name of the Component instance if it has been added to this Pipeline or an empty string otherwise.

        :param instance:
            The Component instance to look for.
        :returns:
            The name of the Component instance.
        """
        for name, inst in self.graph.nodes(data="instance"):
            if inst == instance:
                return name
        return ""

    def inputs(self, include_components_with_connected_inputs: bool = False) -> dict[str, dict[str, Any]]:
        """
        Returns a dictionary containing the inputs of a pipeline.

View on GitHub (pinned to e318778c9b)

Solutions

  1. List existing names first (pipeline.list_component_names() or pipeline.graph.nodes keys) and correct the name
  2. Ensure the component is added with pipeline.add_component(name, ...) before get/remove
  3. Check the exact spelling/case of the name

Example fix

// before
comp = pipeline.get_component('retrievr')
// after
comp = pipeline.get_component('retriever')
Defensive patterns

Strategy: validation

Validate before calling

names = pipeline.list_component_names()
assert name in names, f"{name!r} not in pipeline; available: {names}"

Type guard

def component_exists(pipeline, name: str) -> bool:
    return name in pipeline.list_component_names()

Try / catch

try:
    comp = pipeline.get_component(name)
except ValueError as e:
    logger.error('%s; available: %s', e, pipeline.list_component_names())

Prevention

When it happens

Trigger: pipeline.get_component('name') or pipeline.remove_component('name') with a name never added, a typo, or a component already removed.

Common situations: Typos in names; assuming default names instead of the ones given in add_component; removing a component twice; storing names in config files that drifted from code.

Related errors


AI-assisted analysis of deepset-ai/haystack@e318778c9b (2026-08-30). Data as JSON: /api/errors/c770676b6c798087. Report an issue: GitHub.