apache/dolphinscheduler · error · java.lang.IllegalArgumentException
The default branch is empty, please check the switch task co
Error message
The default branch is empty, please check the switch task configuration
What it means
SwitchLogicTask.moveToDefaultBranch runs when no condition branch matches; it requires the switch task's configured default/next node to be non-null. When the switch result's nextNode is empty it throws this IllegalArgumentException because the task cannot decide where to route execution.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/switchtask/SwitchLogicTask.java:83
if (CollectionUtils.isEmpty(taskParameters.getSwitchResult().getDependTaskList())) {
// If the branch is empty then will go into the default branch
// This case shouldn't happen, we can directly throw exception and forbid the user to set branch
log.info("The switch items is empty");
moveToDefaultBranch();
} else {
calculateSwitchBranch();
}
checkIfBranchExist(taskParameters.getNextBranch());
taskInstance.setTaskParams(JSONUtils.toJsonString(taskParameters));
onTaskSuccess();
log.info("Switch task execute finished");
}
private void moveToDefaultBranch() {
log.info("Begin to move to the default branch");
if (taskParameters.getSwitchResult().getNextNode() == null) {
throw new IllegalArgumentException(
"The default branch is empty, please check the switch task configuration");
}
taskParameters.setNextBranch(taskParameters.getSwitchResult().getNextNode());
log.info("The condition is not satisfied, move to the default branch: {}",
getTaskName(taskParameters.getNextBranch()));
}
private void calculateSwitchBranch() {
List<SwitchResultVo> switchResultVos = taskParameters.getSwitchResult().getDependTaskList();
Map<String, Property> globalParams = taskExecutionContext.getPrepareParamsMap();
Map<String, Property> varParams = VarPoolUtils.deserializeVarPool(taskInstance.getVarPool())
.stream()
.collect(Collectors.toMap(Property::getProp, Property -> Property));
Long nextBranch = null;
for (SwitchResultVo switchResultVo : switchResultVos) {
log.info("Begin to execute switch item: {} ", switchResultVo);
try {View on GitHub (pinned to 02eac45a1b)
Solutions
- Open the switch task in the workflow editor and set a default (next) branch node
- Ensure at least one condition branch or the default branch is defined before saving
- Re-save the task so SwitchResult.nextNode is persisted in the task parameters
Example fix
// before (task params)
{"switchResult": {"dependTaskList": [...], "nextNode": null}}
// after
{"switchResult": {"dependTaskList": [...], "nextNode": "default_task_name"}} Defensive patterns
Strategy: validation
Validate before calling
SwitchParameters params = ...;
if (params.getSwitchResult() == null
|| params.getSwitchResult().getNextNode() == null) {
throw new IllegalStateException("Switch task must define a default branch");
} Type guard
boolean hasDefaultBranch(SwitchParameters p) {
return p != null && p.getSwitchResult() != null && p.getSwitchResult().getNextNode() != null;
} Try / catch
try {
switchLogicTask.start();
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("default branch is empty")) {
taskFailed("Configure a default branch on the switch task");
}
} Prevention
- Always fill the default branch field when defining switch tasks in the UI
- Add workflow-definition validation that rejects switch tasks without a default branch
- Avoid hand-editing workflow JSON; use the UI/API so nextNode is persisted
When it happens
Trigger: A switch task whose SwitchResult.nextNode is null — the default branch was never configured, or upstream branch calculation left nextNode unset when all conditions evaluated false.
Common situations: Saving a switch task in the UI without selecting a default branch, workflow JSON edited manually dropping the nextNode, or condition expressions failing to parse so no branch matches and the empty default is hit.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- receivers must not be null
- url can not be null
- headerParams is not a valid json
- bodyParams is not a valid json
- requestType is not a valid value
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/c6e1bf9f177ff931.
Report an issue: GitHub.