{"record":{"id":"73997bdc3164d397","repo":"deepset-ai/haystack","slug":"branchjoiner-expects-only-one-input-but-inputs-c","errorCode":null,"errorMessage":"BranchJoiner expects only one input, but {inputs_count} were received.","messagePattern":"BranchJoiner expects only one input, but (.+?) were received\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/components/joiners/branch.py","lineNumber":128,"sourceCode":"        Deserializes a `BranchJoiner` instance from a dictionary.\n\n        :param data: The dictionary containing serialized component data.\n        :returns:\n            A deserialized `BranchJoiner` instance.\n        \"\"\"\n        data[\"init_parameters\"][\"type_\"] = deserialize_type(data[\"init_parameters\"][\"type_\"])\n        return default_from_dict(cls, data)\n\n    def run(self, **kwargs: Any) -> dict[str, Any]:\n        \"\"\"\n        Executes the `BranchJoiner`, selecting the first available input value and passing it downstream.\n\n        :param **kwargs: The input data. Must be of the type declared by `type_` during initialization.\n        :returns:\n            A dictionary with a single key `value`, containing the first input received.\n        \"\"\"\n        if (inputs_count := len(kwargs[\"value\"])) != 1:\n            raise ValueError(f\"BranchJoiner expects only one input, but {inputs_count} were received.\")\n        return {\"value\": kwargs[\"value\"][0]}\n","sourceCodeStart":110,"sourceCodeEnd":130,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/joiners/branch.py#L110-L130","documentation":"BranchJoiner forwards a single value to one of its branches, so exactly one connection may deliver input at runtime. run() raises ValueError when more than one value arrives on the 'value' input, because it cannot know which to forward.","triggerScenarios":"Wiring two or more components' outputs into BranchJoiner.value, then running the pipeline so multiple inputs arrive simultaneously (e.g. in a loop where two branches both emit).","commonSituations":"Pipeline mis-wiring in branching/looping graphs; connecting both a router output and another source to the same joiner input; forgetting that conditional execution still counts every connected sender that fires.","solutions":["Inspect pipeline connections (pipeline.draw()/show()) and remove all but one edge into BranchJoiner.value.","Use a different component (e.g. DocumentJoiner or AnswerJoiner) if merging multiple inputs is intended.","Re-structure the pipeline with a Router component so only one sender fires per run."],"exampleFix":"# before\npipeline.connect(router.unmatched, joiner.value)\npipeline.connect(other_comp.output, joiner.value)\n// after\npipeline.connect(router.matched, joiner.value)  # only one connection to joiner.value","handlingStrategy":"validation","validationCode":"senders = [c for c in pipeline.connections() if c[1] == (\"joiner\", \"value\")]\nif len(senders) > 1:\n    raise ValueError(f\"BranchJoiner.value must have exactly one sender, has {len(senders)}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = pipeline.run({\"query\": q})\nexcept ValueError as e:\n    if \"BranchJoiner expects only one input\" in str(e):\n        raise RuntimeError(\"Pipeline mis-wired: multiple edges into BranchJoiner.value\") from e\n    raise","preventionTips":["Draw the pipeline (pipeline.draw()) to inspect wiring","Connect exactly one output to BranchJoiner.value","Use a Router for one-of-many routing and a Joiner only for merging"],"tags":["pipeline-wiring","python","haystack"],"backgroundTag":"multiple-inputs-connected","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}