Skip to content

fix: preserve BreakpointException and PipelineRuntimeError in _run_component_async - #12174

Closed
rautaditya2606 wants to merge 3 commits into
deepset-ai:mainfrom
rautaditya2606:fix/async-breakpoint-exception
Closed

fix: preserve BreakpointException and PipelineRuntimeError in _run_component_async#12174
rautaditya2606 wants to merge 3 commits into
deepset-ai:mainfrom
rautaditya2606:fix/async-breakpoint-exception

Conversation

@rautaditya2606

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes

  • Added except BreakpointException: raise and except PipelineRuntimeError: raise clauses to _run_component_async in pipeline.py, before the general except Exception handler, mirroring the existing logic in the synchronous _run_component.
  • Added regression test test_run_component_async_propagates_breakpoint_exception, which calls _run_component_async directly with a break_point and asserts that BreakpointException is propagated instead of being wrapped.
  • Added regression test test_run_component_async_does_not_rewrap_pipeline_runtime_error, using a component that raises PipelineRuntimeError directly and asserting that the same exception instance propagates through run_async.
  • Added a release note.

How did you test it?

hatch run test:unit test/core/pipeline/test_async_pipeline.py
hatch run test:unit test/core/pipeline/test_breakpoint.py
hatch run test:types haystack/core/pipeline/pipeline.py

All 21 async pipeline tests and 32 breakpoint tests pass. mypy reports no issues.

Notes for the reviewer

  • The change is strictly additive: two new except clauses are inserted before the existing generic exception handler. The normal execution path is unchanged.
  • BreakpointException is raised before _execute_component_async is called, so the previous except Exception block always intercepted it and wrapped it in a new PipelineRuntimeError, preventing callers from handling breakpoints correctly.
  • Preserving PipelineRuntimeError also maintains parity with the synchronous implementation and avoids unnecessary double-wrapping for nested pipelines (for example, Agent components), preserving the original exception context.

Checklist

…mponent_async

The async path had a bare 'except Exception' that wrapped both
BreakpointException and PipelineRuntimeError into a new
PipelineRuntimeError. This silently broke breakpoints in run_async /
run_async_generator / stream and caused nested pipeline errors (e.g.
from Agent) to lose their original context.

Mirror the sync _run_component behaviour: re-raise both exception types
as-is and only wrap unknown exceptions.

Includes two regression tests and a release note.
Copilot AI review requested due to automatic review settings July 28, 2026 09:22
@rautaditya2606
rautaditya2606 requested a review from a team as a code owner July 28, 2026 09:22
@rautaditya2606
rautaditya2606 requested review from davidsbatista and removed request for a team July 28, 2026 09:22
@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

  • Fixes async pipeline error handling to match sync behavior by re-raising BreakpointException and PipelineRuntimeError from Pipeline._run_component_async instead of wrapping them.

Changes:

  • Added explicit except BreakpointException: raise and except PipelineRuntimeError: raise in haystack/core/pipeline/pipeline.py before the generic except Exception.
  • Added regression tests covering async propagation behavior for BreakpointException and PipelineRuntimeError.
  • Added a release note documenting the fix and its impact on async breakpoints / nested pipeline errors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
haystack/core/pipeline/pipeline.py Re-raises BreakpointException/PipelineRuntimeError in _run_component_async to avoid accidental wrapping.
test/core/pipeline/test_async_pipeline.py Adds async regression tests for breakpoint propagation and avoiding double-wrapping PipelineRuntimeError.
releasenotes/notes/fix-async-breakpoint-exception-980c389b99a94039.yaml Release note describing the async exception propagation fix.
Comments suppressed due to low confidence (1)

test/core/pipeline/test_async_pipeline.py:580

  • test_run_component_async_propagates_breakpoint_exception currently triggers the breakpoint via the break_point argument, which raises BreakpointException before _execute_component_async runs; this means the test does not exercise the new except BreakpointException: branch inside the try and would likely have passed even before this PR.
    break_point = Breakpoint(component_name="comp", visit_count=0)
    component_visits = {"comp": 0}
    comp = pipeline._get_component_with_graph_metadata_and_visits("comp", 0)

    # _run_component_async must raise BreakpointException, not wrap it in PipelineRuntimeError.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +561 to +565
Before the fix, a bare ``except Exception`` in _run_component_async would catch the
BreakpointException raised at the start of that method (before _execute_component_async
is even called) and wrap it in a PipelineRuntimeError, silently breaking the breakpoint
feature for the async path.
"""
@sjrl

sjrl commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@davidsbatista I can take the review of this one

@sjrl

sjrl commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Closing. See motivation here #12173 (comment)

@sjrl sjrl closed this Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/core/pipeline
  pipeline.py 573
Project Total  

This report was generated by python-coverage-comment-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_run_component_async wraps BreakpointException and PipelineRuntimeError instead of re-raising them

3 participants