fail fast invalid task composition#1153
Conversation
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
ValueErrorwhen the same task instance is passed towhen_all/when_anymore than once, previously a silent, permanent hang.ValueErrorwhen a still-pending task that belongs to another pending composite is reused, previously a silent hang.CompositeTask.__init__contract: it replays completions intoon_child_completedduring construction, so subclasses must set their state beforesuper().__init__()and must not reset counters after it._failed_tasksfield (written once, never read; failures flow through_exception).