{"record":{"id":"ab4b854135ad1d1e","repo":"deepset-ai/haystack","slug":"connecting-a-component-to-itself-is-not-supported","errorCode":null,"errorMessage":"Connecting a Component to itself is not supported.","messagePattern":"Connecting a Component to itself is not supported\\.","errorType":"exception","errorClass":"PipelineConnectError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/base.py","lineNumber":620,"sourceCode":"            The component that delivers the value. This can be either just a component name or can be\n            in the format `component_name.connection_name` if the component has multiple outputs.\n        :param receiver:\n            The component that receives the value. This can be either just a component name or can be\n            in the format `component_name.connection_name` if the component has multiple inputs.\n\n        :returns:\n            The Pipeline instance.\n\n        :raises PipelineConnectError:\n            If the two components cannot be connected (for example if one of the components is\n            not present in the pipeline, or the connections don't match by type, and so on).\n        \"\"\"\n        # Edges may be named explicitly by passing 'node_name.edge_name' to connect().\n        sender_component_name, sender_socket_name = parse_connect_string(sender)\n        receiver_component_name, receiver_socket_name = parse_connect_string(receiver)\n\n        if sender_component_name == receiver_component_name:\n            raise PipelineConnectError(\"Connecting a Component to itself is not supported.\")\n\n        # Get the nodes data.\n        try:\n            sender_sockets = self.graph.nodes[sender_component_name][\"output_sockets\"]\n        except KeyError as exc:\n            raise ValueError(f\"Component named {sender_component_name} not found in the pipeline.\") from exc\n        try:\n            receiver_sockets = self.graph.nodes[receiver_component_name][\"input_sockets\"]\n        except KeyError as exc:\n            raise ValueError(f\"Component named {receiver_component_name} not found in the pipeline.\") from exc\n\n        if not sender_sockets:\n            raise PipelineConnectError(\n                f\"'{sender_component_name}' does not have any output connections. \"\n                f\"Please check that the output types of '{sender_component_name}.run' are set, \"\n                f\"for example by using the '@component.output_types' decorator.\"\n            )\n","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/base.py#L602-L638","documentation":"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.","triggerScenarios":"pipe.connect(\"prompt\", \"prompt\"); programmatically building edge lists where sender and receiver variables end up equal; templated generation that did not check name inequality.","commonSituations":"Auto-wiring loops over component names with an off-by-one or identity pairing; copy-paste of connect lines with the wrong receiver edited.","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"],"exampleFix":"// before\npipe.connect(\"prompt_builder\", \"prompt_builder\")\n// after\npipe.connect(\"prompt_builder\", \"llm\")","handlingStrategy":"validation","validationCode":"def is_valid_edge(pipe, sender: str, receiver: str) -> bool:\n    s = sender.split(\".\")[0]\n    r = receiver.split(\".\")[0]\n    return s != r and s in pipe.graph.nodes and r in pipe.graph.nodes","typeGuard":"def is_self_loop(sender: str, receiver: str) -> bool:\n    return sender.split(\".\")[0] == receiver.split(\".\")[0]","tryCatchPattern":"from haystack.core.errors import PipelineConnectError\ntry:\n    pipe.connect(sender, receiver)\nexcept PipelineConnectError as e:\n    if \"to itself\" in str(e):\n        logger.warning(\"Skipped self-connection %s -> %s\", sender, receiver)\n    else:\n        raise","preventionTips":["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"],"tags":["python","pipeline","api-misuse"],"backgroundTag":"invalid-graph-edge","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}