{"record":{"id":"3c0856a572c7b2d0","repo":"apache/dolphinscheduler","slug":"switch-task-params-taskparams-is-invalid","errorCode":null,"errorMessage":"\"Switch task params: \" + taskParams + \" is invalid.\"","messagePattern":"\"Switch task params: \" \\+ taskParams \\+ \" is invalid\\.\"","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/SuccessorFlowAdjuster.java","lineNumber":107,"sourceCode":"        }\n        final ConditionsParameters.ConditionResult conditionResult = conditionsParameters.getConditionResult();\n        if (conditionResult == null) {\n            throw new IllegalArgumentException(\"ConditionResult: is null in taskParam: \" + taskParams);\n        }\n        final List<Long> needSkippedBranch;\n        if (conditionResult.isConditionSuccess()) {\n            needSkippedBranch = conditionResult.getFailedNode();\n        } else {\n            needSkippedBranch = conditionResult.getSuccessNode();\n        }\n        markTaskSkipped(taskExecution, needSkippedBranch);\n    }\n\n    private void adjustSwitchTaskSuccessorFlow(final ITaskExecution taskExecution) {\n        final String taskParams = taskExecution.getTaskInstance().getTaskParams();\n        final SwitchParameters switchParameters = JSONUtils.parseObject(taskParams, SwitchParameters.class);\n        if (switchParameters == null) {\n            throw new IllegalArgumentException(\"Switch task params: \" + taskParams + \" is invalid.\");\n        }\n        final SwitchParameters.SwitchResult switchResult = switchParameters.getSwitchResult();\n        if (switchResult == null) {\n            throw new IllegalArgumentException(\"ConditionResult: is null in taskParam: \" + taskParams);\n        }\n        final Set<Long> needSkippedBranch = new HashSet<>();\n        if (switchResult.getNextNode() != null) {\n            needSkippedBranch.add(switchResult.getNextNode());\n        }\n        if (CollectionUtils.isNotEmpty(switchResult.getDependTaskList())) {\n            for (SwitchResultVo switchResultVo : switchResult.getDependTaskList()) {\n                needSkippedBranch.add(switchResultVo.getNextNode());\n            }\n        }\n        needSkippedBranch.remove(switchParameters.getNextBranch());\n        markTaskSkipped(taskExecution, needSkippedBranch);\n    }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/SuccessorFlowAdjuster.java#L89-L125","documentation":"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.","triggerScenarios":"A switch task instance whose taskParams is null/empty/non-JSON when adjustSuccessorFlow processes the finished switch task.","commonSituations":"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.","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."],"exampleFix":"// before: unparseable params\n\"{switchResult:}\" \n// after: valid SwitchParameters\n{\"switchResult\":{\"dependTaskList\":[{\"condition\":\"${var}>1\",\"nextNode\":1001}],\"nextNode\":1002}}","handlingStrategy":"validation","validationCode":"// validate switch params parse before execution\nSwitchParameters p = JSONUtils.parseObject(taskInstance.getTaskParams(), SwitchParameters.class);\nif (p == null) throw new IllegalStateException(\"Invalid switch task params: \" + taskInstance.getTaskParams());","typeGuard":null,"tryCatchPattern":"try {\n    adjuster.adjustSuccessorFlow(taskExecution);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Switch task params:\")) {\n        // repair the switch task's taskParams JSON\n    } else throw e;\n}","preventionTips":["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."],"tags":["workflow","switch-task","json"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}