[Fix #1148] Add then flow directive to catch clause - #1173
Conversation
…ch clause Add support for the then flow directive in the catch clause of try tasks, enabling control flow transitions after catching errors. This allows multiple try tasks to route to shared error-handling tasks without duplicating inline do blocks. Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds support for a then flow directive in the catch clause of try tasks in the Serverless Workflow DSL, enabling workflows to transition to a shared error-handling task after an error is caught.
Changes:
- Extended the workflow schema to allow
catch.then(as aflowDirective) ontrytasks. - Updated the DSL reference to document the new
thenproperty forcatch. - Added a new example workflow demonstrating
catch.then.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| schema/workflow.yaml | Adds then to TryTaskCatch, referencing the shared flowDirective definition. |
| dsl-reference.md | Documents the new catch.then property in the Catch properties table. |
| examples/try-catch-then-directive.yaml | Adds an example showing then used in a catch clause. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Address review feedback: the `do` block handles the error, this task just records the outcome after catch processing. Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
1535fbc to
045037c
Compare
|
@cdavernas can you have another look please? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
dsl-reference.md:1258
- The ordering/precedence between
catch.doandcatch.thenis still ambiguous for readers: if tasks insidecatch.doinclude their own explicit flow directives (then,end, etc.), it’s unclear whethercatch.thenis ignored, enforced afterdo, or invalid. Consider documenting the exact precedence rules (and any invalid combinations) here and/or in the schema description so authors know which transition wins.
| then | [`flowDirective`](#flow-directive) | `no` | The [flow directive](#flow-directive) to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). This determines the next transition for the catch path (overriding the try task’s normal completion flow). |
dsl-reference.md:1258
- The text uses a typographic apostrophe (’), which can be inconsistent with repos that prefer plain ASCII and can make searching/copy-paste harder. Consider changing
try task’stotry task'sfor consistency.
| then | [`flowDirective`](#flow-directive) | `no` | The [flow directive](#flow-directive) to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). This determines the next transition for the catch path (overriding the try task’s normal completion flow). |
examples/try-catch-then-directive.yaml:26
- The example’s error target task (
recordFailure) doesn’t explicitly terminate or transition. If the DSL allows implicit end-of-list completion this may still work, but it’s less clear for readers and inconsistent withcontinueProcessingwhich explicitlythen: end. Consider adding an explicit terminal transition (e.g.,then: end) so the example unambiguously demonstrates the intended control flow on the catch path.
- recordFailure:
set:
status: failed
3d625a4
into
open-workflow-specification:main
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
schema/workflow.yaml:1060
- The description implies
catch.thenruns after executingcatch.do, but it doesn’t clarify what happens if tasks withincatch.doperform their own flow transitions (e.g., an inner task usesthen,end, etc.). This can make the precedence ambiguous for users. Consider explicitly documenting the precedence/behavior (e.g., whethercatch.thenonly applies when thecatch.dotask list completes via default sequential flow, and whether explicit transitions insidecatch.dobypasscatch.then).
then:
$ref: '#/$defs/flowDirective'
title: TryTaskCatchThen
description: The flow directive to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). When set, this determines the next transition instead of the try task's top-level `then` or the default sequential flow.
dsl-reference.md:1258
- This text also has the same precedence ambiguity as the schema description regarding interactions between
catch.dotask-level transitions andcatch.then. Recommend adding a short clarifying sentence about howcatch.thenbehaves whencatch.dois present and contains tasks that explicitly redirect control flow.
| then | [`flowDirective`](#flow-directive) | `no` | The [flow directive](#flow-directive) to execute for the error path after the error has been caught (and after executing any `do` tasks, if set). This determines the next transition for the catch path (overriding the try task’s normal completion flow). |
Summary
thenproperty (typeflowDirective) to thecatchclause oftrytasksthen: handleErrorto jump to a shared error-handling task)doblocks when multipletrytasks need the same error-handling sequenceChanges
schema/workflow.yaml: Addedthenproperty referencingflowDirectivetoTryTaskCatchdsl-reference.md: Addedthenrow to the Catch properties tableexamples/try-catch-then-directive.yaml: New example demonstrating thethendirective in a catch clauseTest plan
Fixes #1148