Skip to content

[Fix #1601] Implement then on catch - #1609

Merged
fjtirado merged 2 commits into
open-workflow-specification:mainfrom
fjtirado:Fix_#1601
Aug 7, 2026
Merged

[Fix #1601] Implement then on catch#1609
fjtirado merged 2 commits into
open-workflow-specification:mainfrom
fjtirado:Fix_#1601

Conversation

@fjtirado

@fjtirado fjtirado commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Fix #1601

Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
Copilot AI lite review requested due to automatic review settings August 7, 2026 13:02

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

Adds support for a then directive on try...catch blocks (issue #1601), and refactors the executor builder generics to preserve concrete executor types through the builder hierarchy.

Changes:

  • Implement handling of catch.then in TryExecutor by building a separate catch transition and applying it when a catch matches.
  • Refactor RegularTaskExecutorBuilder to be generic on both task type and executor type, updating all affected executors’ builders accordingly.
  • Add a workflow sample and extend an existing parameterized test to cover catch.then.

Reviewed changes

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

Show a summary per file
File Description
impl/test/src/test/resources/workflows-samples/try-catch-match-then.yaml Adds a sample workflow that uses catch.then to redirect execution after a handled error.
impl/test/src/test/java/io/serverlessworkflow/impl/test/RetryTimeoutTest.java Extends parameterized coverage to include the new catch.then sample.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/WaitExecutor.java Updates builder type parameters to match the new RegularTaskExecutorBuilder<T, V> signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Implements catch.then transition wiring and alters execution/transition behavior for try/catch.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/SetExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/RunTaskExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/RegularTaskExecutor.java Refactors the regular executor builder to carry the concrete executor type and simplifies execute chaining.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/RaiseExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/ListenExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForkExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/EmitExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/DoExecutor.java Updates builder generics to the new base builder signature.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallTaskExecutor.java Updates builder generics to the new base builder signature.

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

Signed-off-by: Francisco Javier Tirado Sarti <ftirados@ibm.com>
Copilot AI review requested due to automatic review settings August 7, 2026 17:14

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

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

Suppressed comments (2)

impl/test/src/test/resources/workflows-samples/try-catch-retry-inline-then.yaml:21

  • The catch.then block is currently written as a nested mapping (then: followed by an indented bare key), which YAML parses as an object (e.g., {endGracefully: null}) rather than the intended scalar flow directive. This is inconsistent with the other sample (then: endGracefully) and can break parsing/binding to FlowDirective.
        then:
            endGracefully

impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java:80

  • catchTransitionBuilder is never initialized, so if this builder is built without a prior connect(...) call (e.g., TaskExecutorHelper.createBranchList(...) builds executors without calling connect), buildTransition(...) will throw a NullPointerException when it calls catchTransitionBuilder.map(...). Initialize it to Optional.empty() so buildTransition(...) is safe regardless of whether connect(...) ran.
    private final FlowDirective catchDirective;
    private Optional<TransitionInfoBuilder> catchTransitionBuilder;
    private String errorVariable;

@fjtirado
fjtirado merged commit 3542a12 into open-workflow-specification:main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support then in try catch

3 participants