apache/dolphinscheduler · error · IllegalArgumentException
"Switch task params: " + taskParams + " is invalid."
Error message
"Switch task params: " + taskParams + " is invalid."
What it means
Thrown by SuccessorFlowAdjuster.adjustSwitchTaskSuccessorFlow when the switch task's taskParams cannot be parsed into a SwitchParameters object. The master must parse SwitchParameters to know which successor to keep and which to skip. Null parse result indicates empty, malformed, or wrong-shape params JSON.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/SuccessorFlowAdjuster.java:107
}
final ConditionsParameters.ConditionResult conditionResult = conditionsParameters.getConditionResult();
if (conditionResult == null) {
throw new IllegalArgumentException("ConditionResult: is null in taskParam: " + taskParams);
}
final List<Long> needSkippedBranch;
if (conditionResult.isConditionSuccess()) {
needSkippedBranch = conditionResult.getFailedNode();
} else {
needSkippedBranch = conditionResult.getSuccessNode();
}
markTaskSkipped(taskExecution, needSkippedBranch);
}
private void adjustSwitchTaskSuccessorFlow(final ITaskExecution taskExecution) {
final String taskParams = taskExecution.getTaskInstance().getTaskParams();
final SwitchParameters switchParameters = JSONUtils.parseObject(taskParams, SwitchParameters.class);
if (switchParameters == null) {
throw new IllegalArgumentException("Switch task params: " + taskParams + " is invalid.");
}
final SwitchParameters.SwitchResult switchResult = switchParameters.getSwitchResult();
if (switchResult == null) {
throw new IllegalArgumentException("ConditionResult: is null in taskParam: " + taskParams);
}
final Set<Long> needSkippedBranch = new HashSet<>();
if (switchResult.getNextNode() != null) {
needSkippedBranch.add(switchResult.getNextNode());
}
if (CollectionUtils.isNotEmpty(switchResult.getDependTaskList())) {
for (SwitchResultVo switchResultVo : switchResult.getDependTaskList()) {
needSkippedBranch.add(switchResultVo.getNextNode());
}
}
needSkippedBranch.remove(switchParameters.getNextBranch());
markTaskSkipped(taskExecution, needSkippedBranch);
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Repair the switch task's taskParams JSON to match SwitchParameters (switchResult with dependTaskList and nextNode).
- Re-save the switch task via the UI to regenerate canonical params, then re-run the workflow.
- Audit any tooling that writes task definitions directly and validate params JSON before saving.
Example fix
// before: unparseable params
"{switchResult:}"
// after: valid SwitchParameters
{"switchResult":{"dependTaskList":[{"condition":"${var}>1","nextNode":1001}],"nextNode":1002}} Defensive patterns
Strategy: validation
Validate before calling
// validate switch params parse before execution
SwitchParameters p = JSONUtils.parseObject(taskInstance.getTaskParams(), SwitchParameters.class);
if (p == null) throw new IllegalStateException("Invalid switch task params: " + taskInstance.getTaskParams()); Try / catch
try {
adjuster.adjustSuccessorFlow(taskExecution);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Switch task params:")) {
// repair the switch task's taskParams JSON
} else throw e;
} Prevention
- Create switch tasks through the UI so SwitchParameters JSON is well-formed.
- Validate taskParams JSON against the SwitchParameters schema in any automation.
- Avoid direct DB edits to task definitions.
When it happens
Trigger: A switch task instance whose taskParams is null/empty/non-JSON when adjustSuccessorFlow processes the finished switch task.
Common situations: Hand-edited task params in the database; malformed payload from a custom API client creating switch tasks; params JSON written with the wrong top-level structure so deserialization yields null.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- Failed to parse Switch task params: {taskParams}
- The branch is empty, please check the switch task configurat
- The branch(code= ${branchNode}) is not in the dag, please ch
- Condition task params: ${taskParams} is invalid.
- itemsList is null
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/3c0856a572c7b2d0.
Report an issue: GitHub.