Skip to content

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

Closed
nthmost-orkes wants to merge 1 commit into
conductor-oss:mainfrom
nthmost-orkes:fix/396-switch-empty-case-falls-through-to-default
Closed

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

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 that asserts only the SWITCH task itself is scheduled (not the defaultCase task) 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
@nthmost-orkes nthmost-orkes force-pushed the fix/396-switch-empty-case-falls-through-to-default branch from e167d5a to 9ec2739 Compare June 8, 2026 22:36
@nthmost-orkes

Copy link
Copy Markdown
Contributor Author

Closing to reopen with a clean commit history.

@nthmost-orkes nthmost-orkes deleted the fix/396-switch-empty-case-falls-through-to-default branch June 8, 2026 22:38
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