deepset-ai/haystack · error · PipelineConnectError
Connecting a Component to itself is not supported.
Error message
Connecting a Component to itself is not supported.
What it means
Pipeline edges connect two distinct components. connect(sender, receiver) rejects calls where both strings refer to the same component, since a self-loop has no meaningful input/output socket pairing, raising PipelineConnectError.
Source
Thrown at haystack/core/pipeline/base.py:620
The component that delivers the value. This can be either just a component name or can be
in the format `component_name.connection_name` if the component has multiple outputs.
:param receiver:
The component that receives the value. This can be either just a component name or can be
in the format `component_name.connection_name` if the component has multiple inputs.
:returns:
The Pipeline instance.
:raises PipelineConnectError:
If the two components cannot be connected (for example if one of the components is
not present in the pipeline, or the connections don't match by type, and so on).
"""
# Edges may be named explicitly by passing 'node_name.edge_name' to connect().
sender_component_name, sender_socket_name = parse_connect_string(sender)
receiver_component_name, receiver_socket_name = parse_connect_string(receiver)
if sender_component_name == receiver_component_name:
raise PipelineConnectError("Connecting a Component to itself is not supported.")
# Get the nodes data.
try:
sender_sockets = self.graph.nodes[sender_component_name]["output_sockets"]
except KeyError as exc:
raise ValueError(f"Component named {sender_component_name} not found in the pipeline.") from exc
try:
receiver_sockets = self.graph.nodes[receiver_component_name]["input_sockets"]
except KeyError as exc:
raise ValueError(f"Component named {receiver_component_name} not found in the pipeline.") from exc
if not sender_sockets:
raise PipelineConnectError(
f"'{sender_component_name}' does not have any output connections. "
f"Please check that the output types of '{sender_component_name}.run' are set, "
f"for example by using the '@component.output_types' decorator."
)
View on GitHub (pinned to e318778c9b)
Solutions
- Connect the component to a different component, or insert an intermediary component between them
- If self-processing is intended, do it inside the component's run() rather than via an edge
- Assert sender != receiver in code that generates connections dynamically
Example fix
// before
pipe.connect("prompt_builder", "prompt_builder")
// after
pipe.connect("prompt_builder", "llm") Defensive patterns
Strategy: validation
Validate before calling
def is_valid_edge(pipe, sender: str, receiver: str) -> bool:
s = sender.split(".")[0]
r = receiver.split(".")[0]
return s != r and s in pipe.graph.nodes and r in pipe.graph.nodes Type guard
def is_self_loop(sender: str, receiver: str) -> bool:
return sender.split(".")[0] == receiver.split(".")[0] Try / catch
from haystack.core.errors import PipelineConnectError
try:
pipe.connect(sender, receiver)
except PipelineConnectError as e:
if "to itself" in str(e):
logger.warning("Skipped self-connection %s -> %s", sender, receiver)
else:
raise Prevention
- Assert sender != receiver in code that generates edges dynamically
- Do intra-component processing inside run(), not via edges
- Review generated edge lists for identity pairings
When it happens
Trigger: pipe.connect("prompt", "prompt"); programmatically building edge lists where sender and receiver variables end up equal; templated generation that did not check name inequality.
Common situations: Auto-wiring loops over component names with an off-by-one or identity pairing; copy-paste of connect lines with the wrong receiver edited.
Related errors
- Component instance cannot be added to the pipeline more than
- '{type(instance)}' doesn't seem to be a component. Is this c
- Component has already been added to this Pipeline under the
- There is no component named '{name}' in the pipeline. The va
- 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/ab4b854135ad1d1e.
Report an issue: GitHub.