{"record":{"id":"c6e1bf9f177ff931","repo":"apache/dolphinscheduler","slug":"the-default-branch-is-empty-please-check-the-swit","errorCode":null,"errorMessage":"The default branch is empty, please check the switch task configuration","messagePattern":"The default branch is empty, please check the switch task configuration","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/switchtask/SwitchLogicTask.java","lineNumber":83,"sourceCode":"        if (CollectionUtils.isEmpty(taskParameters.getSwitchResult().getDependTaskList())) {\n            // If the branch is empty then will go into the default branch\n            // This case shouldn't happen, we can directly throw exception and forbid the user to set branch\n            log.info(\"The switch items is empty\");\n            moveToDefaultBranch();\n        } else {\n            calculateSwitchBranch();\n        }\n        checkIfBranchExist(taskParameters.getNextBranch());\n        taskInstance.setTaskParams(JSONUtils.toJsonString(taskParameters));\n\n        onTaskSuccess();\n        log.info(\"Switch task execute finished\");\n    }\n\n    private void moveToDefaultBranch() {\n        log.info(\"Begin to move to the default branch\");\n        if (taskParameters.getSwitchResult().getNextNode() == null) {\n            throw new IllegalArgumentException(\n                    \"The default branch is empty, please check the switch task configuration\");\n        }\n        taskParameters.setNextBranch(taskParameters.getSwitchResult().getNextNode());\n        log.info(\"The condition is not satisfied, move to the default branch: {}\",\n                getTaskName(taskParameters.getNextBranch()));\n    }\n\n    private void calculateSwitchBranch() {\n        List<SwitchResultVo> switchResultVos = taskParameters.getSwitchResult().getDependTaskList();\n        Map<String, Property> globalParams = taskExecutionContext.getPrepareParamsMap();\n        Map<String, Property> varParams = VarPoolUtils.deserializeVarPool(taskInstance.getVarPool())\n                .stream()\n                .collect(Collectors.toMap(Property::getProp, Property -> Property));\n\n        Long nextBranch = null;\n        for (SwitchResultVo switchResultVo : switchResultVos) {\n            log.info(\"Begin to execute switch item: {} \", switchResultVo);\n            try {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/executor/plugin/switchtask/SwitchLogicTask.java#L65-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (task params)\n{\"switchResult\": {\"dependTaskList\": [...], \"nextNode\": null}}\n// after\n{\"switchResult\": {\"dependTaskList\": [...], \"nextNode\": \"default_task_name\"}}","handlingStrategy":"validation","validationCode":"SwitchParameters params = ...;\nif (params.getSwitchResult() == null\n        || params.getSwitchResult().getNextNode() == null) {\n    throw new IllegalStateException(\"Switch task must define a default branch\");\n}","typeGuard":"boolean hasDefaultBranch(SwitchParameters p) {\n    return p != null && p.getSwitchResult() != null && p.getSwitchResult().getNextNode() != null;\n}","tryCatchPattern":"try {\n    switchLogicTask.start();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"default branch is empty\")) {\n        taskFailed(\"Configure a default branch on the switch task\");\n    }\n}","preventionTips":["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"],"tags":["switch-task","configuration","task-execution"],"backgroundTag":"missing-required-config-field","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}