{"record":{"id":"0de2dafbf97fe0bd","repo":"deepset-ai/haystack","slug":"pipelineruntimeerror-from-exception-component-name","errorCode":null,"errorMessage":"PipelineRuntimeError.from_exception(component_name, instance.__class__, error)","messagePattern":"PipelineRuntimeError\\.from_exception\\(component_name, instance\\.__class__, error\\)","errorType":"exception","errorClass":"PipelineRuntimeError","httpStatus":null,"severity":"error","filePath":"haystack/core/pipeline/pipeline.py","lineNumber":185,"sourceCode":"\n            try:\n                component_output = instance.run(**inputs_copy)\n            except BreakpointException as error:\n                # Re-raise BreakpointException to preserve the original exception context\n                # This is important when Agent components internally use Pipeline._run_component\n                # and trigger breakpoints that need to bubble up to the main pipeline\n                raise error\n\n            # Any components that internally use Pipeline._run_component could raise a PipelineRuntimeError with\n            # additional context (e.g. Agent raises an agent snapshot) so we re-raise here instead of wrapping it in\n            # another PipelineRuntimeError\n\n            except PipelineRuntimeError as runtime_error:\n                raise runtime_error\n\n            # Catch all other exceptions and wrap them in a PipelineRuntimeError\n            except Exception as error:\n                raise PipelineRuntimeError.from_exception(component_name, instance.__class__, error) from error\n\n            component_visits[component_name] += 1\n\n            if not isinstance(component_output, Mapping):\n                raise PipelineRuntimeError.from_invalid_output(component_name, instance.__class__, component_output)\n\n            _validate_component_output_keys(component_name, component, component_output)\n\n            span.set_tag(_COMPONENT_VISITS, component_visits[component_name])\n            span.set_content_tag(_COMPONENT_OUTPUT, component_output)\n\n            return component_output\n\n    @mark_deserialization_internal\n    def run(  # noqa: PLR0915, PLR0912, C901\n        self,\n        data: dict[str, Any],\n        include_outputs_from: set[str] | None = None,","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/core/pipeline/pipeline.py#L167-L203","documentation":"When a pipeline component's run() raises any exception that is not already a PipelineRuntimeError, Haystack wraps it in a PipelineRuntimeError carrying the component name and class, preserving the original exception via __cause__. The placeholder shown is the factory call used to build it.","triggerScenarios":"Any component raising inside Pipeline.run(): a ValueError in a custom component, an HTTP error inside aFetcher/Retriever, division by zero in user code, etc.","commonSituations":"Bugs in custom components, expired API keys causing requests to fail, bad input data to a component, dependency errors inside third-party components.","solutions":["Read the chained 'Caused by' stacktrace to find the original exception and failing component","Fix the root cause inside the named component (check the component_name in the message)","Wrap known-fragile component code in try/except or validate inputs before run()","Run the component in isolation with the same inputs to reproduce"],"exampleFix":"// before\nclass MyComp:\n    def run(self, x):\n        return {\"out\": 1 / x}\n// after\nclass MyComp:\n    def run(self, x):\n        if x == 0:\n            raise ValueError(\"x must be non-zero\")\n        return {\"out\": 1 / x}","handlingStrategy":"try-catch","validationCode":"# Reproduce the component in isolation before the pipeline run\nout = my_component.run(**inputs)\nassert isinstance(out, dict)","typeGuard":null,"tryCatchPattern":"from haystack.core.errors import PipelineRuntimeError\ntry:\n    result = pipeline.run({\"q\": query})\nexcept PipelineRuntimeError as e:\n    logger.error(\"Component %s failed\", e)\n    logger.debug(\"Root cause\", exc_info=e.__cause__)","preventionTips":["Always inspect e.__cause__ / 'Caused by' for the true error","Test custom components standalone before wiring into the pipeline","Add input validation inside fragile components","Keep the component name in logs to locate failures quickly"],"tags":["python","pipeline","component-execution","error-wrapping"],"backgroundTag":"component-execution-failed","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}