Skip to content

fail fast invalid task composition#1153

Merged
acroca merged 1 commit into
dapr:mainfrom
acroca:task-guards
Jul 15, 2026
Merged

fail fast invalid task composition#1153
acroca merged 1 commit into
dapr:mainfrom
acroca:task-guards

Conversation

@acroca

@acroca acroca commented Jul 15, 2026

Copy link
Copy Markdown
Member
  • Raise ValueError when the same task instance is passed to when_all/when_any more than once, previously a silent, permanent hang.
  • Raise ValueError when a still-pending task that belongs to another pending composite is reused, previously a silent hang.
  • Document the CompositeTask.__init__ contract: it replays completions into on_child_completed during construction, so subclasses must set their state before super().__init__() and must not reset counters after it.
  • Remove the dead _failed_tasks field (written once, never read; failures flow through _exception).

Signed-off-by: Albert Callarisa <albert@diagrid.io>
@acroca
acroca requested review from a team as code owners July 15, 2026 10:35
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.85%. Comparing base (fce592c) to head (9e6dcbf).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1153      +/-   ##
==========================================
+ Coverage   82.84%   82.85%   +0.01%     
==========================================
  Files         123      123              
  Lines       10121    10127       +6     
==========================================
+ Hits         8385     8391       +6     
  Misses       1736     1736              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

This PR improves the Durable Task composition layer in dapr.ext.workflow._durabletask by failing fast on invalid composite construction patterns that previously caused silent, permanent hangs, and by clarifying the CompositeTask.__init__ construction contract.

Changes:

  • Add validation to reject duplicate child task instances in when_all/when_any.
  • Add validation to reject reusing a pending task that is still owned by another pending composite.
  • Add/extend tests covering these fail-fast behaviors and sequential reuse after composite completion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dapr/ext/workflow/_durabletask/task.py Adds fail-fast validation in CompositeTask.__init__, updates related comments/docs, and removes the unused _failed_tasks field.
tests/ext/workflow/durabletask/test_task.py Adds unit tests verifying duplicates and overlapping composite ownership are rejected, and that reuse after completion remains allowed.

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

Comment thread dapr/ext/workflow/_durabletask/task.py
Comment thread dapr/ext/workflow/_durabletask/task.py

@sicoyle sicoyle 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.

lgtm - thank you!!

@acroca
acroca added this pull request to the merge queue Jul 15, 2026
Merged via the queue into dapr:main with commit ec567bf Jul 15, 2026
25 of 26 checks passed
acroca added a commit that referenced this pull request Jul 15, 2026
(cherry picked from commit ec567bf)

Signed-off-by: Albert Callarisa <albert@diagrid.io>
Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com>
Co-authored-by: Albert Callarisa <albert@diagrid.io>
@acroca
acroca deleted the task-guards branch July 15, 2026 14:57
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.

3 participants