{"record":{"id":"b0ca67f04b321ce2","repo":"deepset-ai/haystack","slug":"output-names-in-output-mapping-must-be-strings","errorCode":null,"errorMessage":"Output names in output_mapping must be strings.","messagePattern":"Output names in output_mapping must be strings\\.","errorType":"exception","errorClass":"InvalidMappingTypeError","httpStatus":null,"severity":"error","filePath":"haystack/core/super_component/super_component.py","lineNumber":296,"sourceCode":"                input_mapping[socket_name].append(f\"{comp_name}.{socket_name}\")\n        return input_mapping\n\n    def _validate_output_mapping(\n        self, pipeline_outputs: dict[str, dict[str, Any]], output_mapping: dict[str, str]\n    ) -> None:\n        \"\"\"\n        Validates the output mapping to ensure that specified components and sockets exist in the pipeline.\n\n        :param pipeline_outputs: A dictionary containing pipeline output specifications.\n        :param output_mapping: A dictionary mapping pipeline socket paths to wrapper output names.\n        :raises InvalidMappingTypeError:\n            If the output mapping is of invalid type or contains invalid types.\n        :raises InvalidMappingValueError:\n            If the output mapping contains nonexistent components or sockets.\n        \"\"\"\n        for pipeline_output_path, wrapper_output_name in output_mapping.items():\n            if not isinstance(wrapper_output_name, str):\n                raise InvalidMappingTypeError(\"Output names in output_mapping must be strings.\")\n            comp_name, socket_name = self._split_component_path(pipeline_output_path)\n            if comp_name not in pipeline_outputs:\n                raise InvalidMappingValueError(f\"Component '{comp_name}' not found among pipeline outputs.\")\n            if socket_name not in pipeline_outputs[comp_name]:\n                raise InvalidMappingValueError(f\"Output socket '{socket_name}' not found in component '{comp_name}'.\")\n\n    def _resolve_output_types_from_mapping(\n        self, pipeline_outputs: dict[str, dict[str, Any]], output_mapping: dict[str, str]\n    ) -> dict[str, Any]:\n        \"\"\"\n        Resolves and validates output types based on the provided output mapping.\n\n        This function ensures that all mapped pipeline outputs are correctly assigned to\n        the corresponding SuperComponent outputs while preventing duplicate output names.\n\n        :param pipeline_outputs: A dictionary containing pipeline output specifications.\n        :param output_mapping: A dictionary mapping pipeline output socket paths to SuperComponent output names.\n        :returns:","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/super_component/super_component.py#L278-L314","documentation":"In output_mapping, values are the wrapper's output names and must be strings. A non-string value (int, list, None) raises InvalidMappingTypeError.","triggerScenarios":"output_mapping = {\"retriever.documents\": 1} or {\"retriever.documents\": [\"docs\"]}.","commonSituations":"Copying input_mapping-style list values into output_mapping; programmatic construction with non-string keys/values; config typos.","solutions":["Use a plain string for each wrapper output name: {\"component.socket\": \"docs\"}"],"exampleFix":"// before\noutput_mapping = {\"retriever.documents\": [\"docs\"]}\n// after\noutput_mapping = {\"retriever.documents\": \"docs\"}","handlingStrategy":"validation","validationCode":"def ensure_output_names_str(output_mapping):\n    for path, name in output_mapping.items():\n        if not isinstance(name, str):\n            raise TypeError(f\"output name for '{path}' must be a string, got {type(name).__name__}\")","typeGuard":"def is_valid_output_mapping(v: object) -> bool:\n    return isinstance(v, dict) and all(isinstance(name, str) for name in v.values())","tryCatchPattern":"from haystack.core.errors import InvalidMappingTypeError\ntry:\n    super_comp = SuperComponent(pipeline=pipe, output_mapping=output_mapping)\nexcept InvalidMappingTypeError as e:\n    if \"must be strings\" in str(e):\n        output_mapping = {k: v[0] if isinstance(v, list) and v else str(v) for k, v in output_mapping.items()}\n        super_comp = SuperComponent(pipeline=pipe, output_mapping=output_mapping)\n    else:\n        raise","preventionTips":["Values in output_mapping are output names: plain strings only","Do not reuse input_mapping list-style values for output_mapping","Validate mapping config shapes before constructing SuperComponent"],"tags":["super-component","output-mapping","type-validation"],"backgroundTag":"invalid-mapping-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}