Skip to content

no-issue: fix merging task items; determining names for multipe tass calls#1263

Merged
ricardozanini merged 3 commits intoserverlessworkflow:mainfrom
ricardozanini:fix-multi-task
Mar 23, 2026
Merged

no-issue: fix merging task items; determining names for multipe tass calls#1263
ricardozanini merged 3 commits intoserverlessworkflow:mainfrom
ricardozanini:fix-multi-task

Conversation

@ricardozanini
Copy link
Member

Many thanks for submitting your Pull Request ❤️!
Follow up for #1253

What this PR does / why we need it:

Special notes for reviewers:

Additional information (if needed):

… calls

Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Copilot AI review requested due to automatic review settings March 23, 2026 15:29
@ricardozanini ricardozanini requested a review from fjtirado as a code owner March 23, 2026 15:29
Copy link
Contributor

Copilot AI left a comment

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 follows up on #1253 to ensure deterministic, non-duplicating auto-generated task names when task lists are appended via multiple fluent DSL calls (top-level WorkflowBuilder.tasks(...) and nested constructs like fork.branches(...), forEach.tasks(...), tryCatch.tryHandler(...), etc.).

Changes:

  • Introduces a list-size offset mechanism in task list builders so default names continue sequentially across multiple appends.
  • Updates several builders (workflow/do, fork branches, for-each tasks, subscription iterator tasks, try/catch handlers) to merge newly built tasks into existing lists instead of replacing them.
  • Adds/extends unit tests in both fluent/spec and experimental/fluent/func to cover multi-append naming and merge behavior.

Reviewed changes

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

Show a summary per file
File Description
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseWorkflowBuilder.java Passes current top-level do size as an offset when appending tasks across multiple .tasks(...) calls.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/WorkflowBuilder.java Updates newDo(...) to accept the offset and construct the do-task builder accordingly.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/DoTaskBuilder.java Accepts offset and forwards it into the underlying TaskItemListBuilder.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseTaskItemListBuilder.java Adds offset-based default naming (type-(size+offset)) and changes child-builder factory signature.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/TaskItemListBuilder.java Updates construction/factory methods and ensures nested builders use the new offset-aware approach.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/ForkTaskBuilder.java Appends/merges branches across repeated branches(...) calls while maintaining naming offsets.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/ForEachTaskBuilder.java Appends/merges nested loop tasks across repeated tasks(...) calls while maintaining naming offsets.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/SubscriptionIteratorBuilder.java Appends/merges subscription iterator tasks across repeated tasks(...) calls while maintaining naming offsets.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/TryTaskBuilder.java Appends/merges tasks across repeated tryHandler(...) and catch doTasks(...) calls while maintaining naming offsets.
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/ListenTaskBuilder.java Adjusts construction to use the new offset-aware TaskItemListBuilder constructor.
fluent/spec/src/test/java/io/serverlessworkflow/fluent/spec/TaskItemDefaultNamingTest.java Adds tests covering multi-append behavior across workflow, fork, for-each, subscription iterator, and try/catch.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncWorkflowBuilder.java Updates functional DSL workflow builder to pass offset into do-task builder creation.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncDoTaskBuilder.java Accepts offset and forwards it into the underlying FuncTaskItemListBuilder.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTaskItemListBuilder.java Updates construction/factory and ensures nested listen uses the same factory for offset-aware sub-builders.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncListenTaskBuilder.java Accepts the list-builder factory to allow offset-aware subscription iterator/task building.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncForkTaskBuilder.java Uses current branch count as offset when appending multiple branch blocks.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncForTaskBuilder.java Uses current task count as offset when appending multiple task blocks.
experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncTaskItemDefaultNamingTest.java Adds functional DSL tests for offset-based naming in nested/append scenarios.
Comments suppressed due to low confidence (2)

experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTaskItemListBuilder.java:39

  • FuncTaskItemListBuilder no longer has a no-arg constructor. Even though this module is marked experimental, the class is public and likely used directly; consider reintroducing public FuncTaskItemListBuilder() delegating to this(0) for backward compatibility and easier usage in tests/examples.
  protected static final String TYPE_FUNCTION = "function";

  public FuncTaskItemListBuilder(final int listOffsetSize) {
    super(listOffsetSize);
  }

  public FuncTaskItemListBuilder(final List<TaskItem> list) {
    super(list);
  }

fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/TaskItemListBuilder.java:34

  • TaskItemListBuilder no longer has a no-arg constructor. Since this class is public and may be instantiated directly by library users, consider reintroducing public TaskItemListBuilder() delegating to this(0) to avoid breaking downstream source/binary compatibility.
  public TaskItemListBuilder(int listOffsetSize) {
    super(listOffsetSize);
  }

  public TaskItemListBuilder(List<TaskItem> list) {
    super(list);
  }

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

Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
@ricardozanini ricardozanini merged commit d66bf84 into serverlessworkflow:main Mar 23, 2026
3 checks passed
@ricardozanini ricardozanini deleted the fix-multi-task branch March 23, 2026 15:48
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.

3 participants