PipelineComponentNotConnectedError
haystack.errors.PipelineComponentNotConnectedError
Stack trace
haystack.errors.PipelineComponentNotConnectedError: Component 'retriever' is not connected to the pipeline. Please connect all components before running the pipeline.
Why it happens
This error occurs because Haystack pipelines require all components to be explicitly connected to form a directed graph. If a component is instantiated but not linked to the pipeline's flow, the pipeline cannot execute and raises this error.
Detection
Before running the pipeline, verify that all components are connected by checking the pipeline's graph structure or catching PipelineComponentNotConnectedError and logging the missing connections.
Causes & fixes
A pipeline component was created but never added or connected to the pipeline graph.
Ensure you add the component to the pipeline using pipeline.add_node() or pipeline.connect_nodes() methods before running.
Incorrect or missing node names in pipeline.connect_nodes() calls causing components to remain unlinked.
Double-check node names and connection calls to confirm all components are properly linked in the pipeline graph.
Using pipeline.run() without building the pipeline graph first.
Always build and connect the pipeline graph completely before calling pipeline.run().
Code: broken vs fixed
from haystack import Pipeline
retriever = SomeRetriever()
pipeline = Pipeline()
# Missing pipeline.add_node() or connect_nodes() calls
result = pipeline.run(query="example") # This line raises PipelineComponentNotConnectedError import os
from haystack import Pipeline
retriever = SomeRetriever()
pipeline = Pipeline()
pipeline.add_node(component=retriever, name="retriever", inputs=["Query"])
# Connected the retriever node properly
result = pipeline.run(query="example") # Now runs without error
print(result)
# Added node to pipeline to fix connection error Workaround
Catch PipelineComponentNotConnectedError and log the missing component names, then manually connect them or fallback to a simpler pipeline configuration.
Prevention
Always build and verify the pipeline graph connections programmatically before running, using pipeline.graph or pipeline.get_nodes() to confirm all components are linked.