no-issue: fix merging task items; determining names for multipe tass calls#1263
Merged
ricardozanini merged 3 commits intoserverlessworkflow:mainfrom Mar 23, 2026
Merged
Conversation
… calls Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
Contributor
There was a problem hiding this comment.
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/specandexperimental/fluent/functo 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 tothis(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 tothis(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.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncDoTaskBuilder.java
Show resolved
Hide resolved
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseWorkflowBuilder.java
Show resolved
Hide resolved
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseTaskItemListBuilder.java
Show resolved
Hide resolved
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseTaskItemListBuilder.java
Show resolved
Hide resolved
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
fjtirado
approved these changes
Mar 23, 2026
fjtirado
approved these changes
Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):