Skip to content

5557 Resolve nested task data pill references and relax label to a warning - #5565

Merged
ivicac merged 3 commits into
masterfrom
5557-nested-task-references
Aug 24, 2026
Merged

5557 Resolve nested task data pill references and relax label to a warning#5565
ivicac merged 3 commits into
masterfrom
5557-nested-task-references

Conversation

@ivicac

@ivicac ivicac commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #5557

Three related defects in platform-workflow-validator, all reachable from one workflow whose branch/v1 cases contain an aiAgent task referenced as ${aiAgent_1}.

1. Bare references to nested tasks reported as non-existent

DataPillValidator.validateTaskReference resolved a pathless data pill (${aiAgent_1}) against ValidationContext.getTaskNames(), which returns a defensive copy — unlike its siblings getAllTasksMap / getTaskNameToTypeMap, which return the live collections. TaskValidator.addNestedTaskToContext was therefore writing every nested task name into a throwaway list, and the registration silently no-opped.

Property references (${aiAgent_1.someField}) were unaffected because they resolve through the live taskNameToTypeMap — which is why only bare references ever showed the error.

Existence now resolves against allTasksMap. The ordered name list is deliberately left alone: it also backs the task-order check via indexOf, and appending nested names there would produce bogus "Wrong task order" errors for a top-level task legitimately referencing a task nested in an earlier dispatcher.

2. Tasks nested in branch/v1 cases were never validated

TaskValidator.processTaskArrayProperty only recognised ARRAY-of-TASK. branch/v1 declares cases as ARRAY-of-OBJECT{key, tasks: ARRAY-of-TASK}, and that one extra object level made everything inside cases[].tasks invisible to structure, parameter and cluster-element validation. (default worked, being a flat ARRAY-of-TASK.) It now descends one object level and recurses into findAndValidateNestedTasks.

3. label was a hard error though the engine treats it as optional

A missing label blocked saving from the workflow code editor (WorkflowCodeEditorSheet disables Save on hasErrors), even though every domain model serialises it only when non-null — WorkflowTask / WorkflowTrigger guard on label != null, and Workflow root / Workflow.Input read it via MapUtils.getString. A missing label on the workflow, its inputs, its triggers and its tasks is now a warning (Missing recommended field: label); a label of the wrong type stays an error, via a new FieldValidator.appendWarningOptionalStringField.

Known gap, not addressed here

WorkflowCodeEditorSheet and WorkflowNodeDetailsPanel render errors only, so validator warnings are not surfaced anywhere in the editor. With label downgraded, that signal is now invisible rather than soft. Surfacing warnings in both panels is worth a separate change.

Tests

  • WorkflowValidatorNestedTaskReferenceTest — bare reference inside a condition, bare reference inside a branch case, structure validation reaching a branch-nested task
  • WorkflowValidatorOptionalLabelTest — workflow / input / trigger / task missing label yields a warning and no error; a non-string label still errors

:platform-workflow-validator-service:check on this branch: 156 tests, 0 failures, spotless / checkstyle / PMD / SpotBugs clean.

🤖 Generated with Claude Code

…rning

Resolve bare data pill references against allTasksMap so tasks nested inside a
task dispatcher are found, descend into branch cases[].tasks when validating
nested tasks, and report a missing label as a warning rather than an error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

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

This PR fixes validation gaps in platform-workflow-validator around nested task handling (especially branch/v1 case tasks) and bare data-pill task references, and changes missing label from an error to a warning so workflows can still be saved while preserving type validation.

Changes:

  • Resolve bare ${taskName} references against the live task registry (including nested tasks) rather than an immutable task-name list.
  • Ensure nested tasks inside branch/v1 cases[].tasks are discovered and validated (structure/params/data pills).
  • Downgrade missing label to a warning across workflow/task/input/trigger validation, while keeping non-string label as an error; add/adjust tests accordingly.

Reviewed changes

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

Show a summary per file
File Description
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/main/java/com/bytechef/platform/workflow/validator/WorkflowValidator.java Threads warnings through structure + input validation and treats workflow label as optional (warning).
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/main/java/com/bytechef/platform/workflow/validator/TaskValidator.java Makes task label optional (warning), improves nested-task discovery for ARRAY<OBJECT{..., tasks: ARRAY<TASK>}>, and plumbs warnings through structure validation APIs.
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/main/java/com/bytechef/platform/workflow/validator/FieldValidator.java Introduces optional-string validation that emits warnings when missing while still erroring on wrong type.
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/main/java/com/bytechef/platform/workflow/validator/DataPillValidator.java Fixes bare task reference existence checks to use the live all-tasks map (nested included).
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/main/java/com/bytechef/platform/workflow/validator/ArrayPropertyValidator.java Passes warnings into nested task-array validation.
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorTest.java Updates existing tests for new warning plumbing and missing-label behavior changes.
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorInputsTest.java Updates missing-input-label expectations from error to warning.
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorDuplicateNodeNamesTest.java Minor doc update (author tag).
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorOptionalLabelTest.java Adds focused coverage for optional label behavior (warnings vs errors).
server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorNestedTaskReferenceTest.java Adds coverage for bare references to nested tasks and for validating tasks nested in branch/v1 cases.
Suppressed comments (1)

server/libs/platform/platform-workflow/platform-workflow-validator/platform-workflow-validator-service/src/test/java/com/bytechef/platform/workflow/validator/WorkflowValidatorNestedTaskReferenceTest.java:68

  • With @ExtendWith(ObjectMapperSetupExtension.class) in place, the @BeforeAll method that mutates the global JsonUtils ObjectMapper should be removed to avoid leaking state between tests.
    public static void beforeAll() {
        JsonUtils.setObjectMapper(
            JsonMapper.builder()
                .build());
    }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

ivicac and others added 2 commits August 24, 2026 17:22
The message a data pill emits for an unknown task read "doesn't exits". It is
rendered in the workflow editor, so the misspelling is user visible. The two
tests asserting the exact string are updated with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…new validator tests

The two tests added for nested task references and the optional label each set
JsonUtils up through their own @BeforeAll, while the project convention is
@ExtendWith(ObjectMapperSetupExtension.class). The extension performs the same
setup for ConvertUtils, MapUtils and XmlUtils as well, so the module gains a
test dependency on test-support.

The five tests that predate this change still use @BeforeAll and are left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ivicac
ivicac merged commit 2f75932 into master Aug 24, 2026
16 checks passed
@ivicac
ivicac deleted the 5557-nested-task-references branch August 24, 2026 15:43
@sonarqubecloud

Copy link
Copy Markdown

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.

[bug] Workflow validator: bare data pill references to tasks nested in a dispatcher fail, and branch cases are never validated

2 participants