{"record":{"id":"117f6a6a0fb34f6b","repo":"deepset-ai/haystack","slug":"pipeline-must-be-provided-to-supercomponent","errorCode":null,"errorMessage":"Pipeline must be provided to SuperComponent.","messagePattern":"Pipeline must be provided to SuperComponent\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/core/super_component/super_component.py","lineNumber":67,"sourceCode":"            ```python\n            input_mapping={\n                \"query\": [\"retriever.query\", \"prompt_builder.query\"],\n            }\n            ```\n        :param output_mapping: A dictionary mapping pipeline output socket paths to component output names.\n            If not provided, a default output mapping will be created based on all pipeline outputs.\n            Example:\n            ```python\n            output_mapping={\n                \"retriever.documents\": \"documents\",\n                \"generator.replies\": \"replies\",\n            }\n            ```\n        :raises InvalidMappingError: Raised if any mapping is invalid or type conflicts occur\n        :raises ValueError: Raised if no pipeline is provided\n        \"\"\"\n        if pipeline is None:\n            raise ValueError(\"Pipeline must be provided to SuperComponent.\")\n\n        self.pipeline: Pipeline = pipeline\n\n        # Determine input types based on pipeline and mapping\n        pipeline_inputs = self.pipeline.inputs()\n        resolved_input_mapping = (\n            input_mapping if input_mapping is not None else self._create_input_mapping(pipeline_inputs)\n        )\n        self._validate_input_mapping(pipeline_inputs, resolved_input_mapping)\n        input_types = self._resolve_input_types_from_mapping(pipeline_inputs, resolved_input_mapping)\n        # Set input types on the component\n        for input_name, info in input_types.items():\n            component.set_input_type(self, name=input_name, **info)\n\n        self.input_mapping: dict[str, list[str]] = resolved_input_mapping\n        self._original_input_mapping = input_mapping\n\n        # Set output types based on pipeline and mapping","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/super_component/super_component.py#L49-L85","documentation":"SuperComponent wraps an existing Pipeline, so a pipeline is mandatory. Constructing SuperComponent without the pipeline argument raises ValueError.","triggerScenarios":"SuperComponent() or SuperComponent(pipeline=None) called without a valid Pipeline instance.","commonSituations":"Refactoring code where the pipeline is built conditionally and ends up None; forgetting to pass pipeline when copying constructor examples; a factory function returning None.","solutions":["Build a Pipeline and pass it: SuperComponent(pipeline=pipe)","Check that the variable holding the pipeline is not None before constructing"],"exampleFix":"// before\nsuper_comp = SuperComponent()\n// after\npipe = Pipeline()\npipe.add_component(\"embedder\", SentenceTransformersTextEmbedder())\nsuper_comp = SuperComponent(pipeline=pipe)","handlingStrategy":"validation","validationCode":"def build_super_component(pipeline):\n    if pipeline is None:\n        raise ValueError(\"pipeline must be a Pipeline instance before creating SuperComponent\")\n    return SuperComponent(pipeline=pipeline)","typeGuard":"from haystack import Pipeline\ndef is_pipeline(p: object) -> bool:\n    return isinstance(p, Pipeline)","tryCatchPattern":"try:\n    super_comp = SuperComponent(pipeline=pipe)\nexcept ValueError as e:\n    if \"Pipeline must be provided\" in str(e):\n        pipe = Pipeline()\n        super_comp = SuperComponent(pipeline=pipe)\n    else:\n        raise","preventionTips":["Always construct the Pipeline before the SuperComponent","Avoid optional pipeline variables that can be None at call time","Initialize pipelines in dedicated factory functions that guarantee a return value"],"tags":["super-component","pipeline","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}