Skip to content

fix: SWITCH task no longer falls through to defaultCase when matched case is empty#1159

Open
nthmost-orkes wants to merge 2 commits into
conductor-oss:mainfrom
nthmost-orkes:fix/396-switch-empty-case-default-fallthrough
Open

fix: SWITCH task no longer falls through to defaultCase when matched case is empty#1159
nthmost-orkes wants to merge 2 commits into
conductor-oss:mainfrom
nthmost-orkes:fix/396-switch-empty-case-default-fallthrough

Conversation

@nthmost-orkes

Copy link
Copy Markdown
Contributor

Summary

  • When a SWITCH task evaluates to a case key that exists in decisionCases but has an empty task list (e.g. "true": []), the workflow was incorrectly executing the defaultCase tasks.
  • Root cause: SwitchTaskMapper treated selectedTasks.isEmpty() the same as selectedTasks == null, collapsing the distinction between "no key matched" and "key matched, no tasks."
  • Fix: remove the isEmpty() check so the fallback only triggers on null (no matching key).

User impact

Users who intentionally defined an empty SWITCH branch (a "no-op" path) saw their workflow take the defaultCase path instead — potentially triggering termination tasks or other unintended steps even though the expression evaluated correctly.

Changes

  • SwitchTaskMapper.java: remove || selectedTasks.isEmpty() from the defaultCase fallback condition
  • SwitchTaskMapperTest.java: add getMappedTasksWithEmptyMatchedCase test asserting only the SWITCH task itself is scheduled when the matched case has no tasks

Fixes #396

…case is empty

An empty decisionCase list (e.g. "true": []) was treated the same as no
matching case, causing the workflow to execute defaultCase tasks even when
the expression evaluated to a known case key. The fallback now triggers
only when no key matches (null), not when the matched case has zero tasks.

Fixes conductor-oss#396
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]: SWITCH task goes through defaultCase if other cases are empty

1 participant