{"record":{"id":"c71696a08de91f26","repo":"apache/dolphinscheduler","slug":"failed-to-parse-condition-task-params-taskparams","errorCode":null,"errorMessage":"Failed to parse Condition task params: {taskParams}","messagePattern":"Failed to parse Condition task params: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":1503,"sourceCode":"            }\n        }\n\n        taskDefLog.setTaskParams(JSONUtils.toJsonString(params));\n    }\n\n    /**\n     * Replaces old task codes with new ones in the parameters of a Condition task.\n     * Used during workflow duplication or import to preserve correct task dependencies.\n     */\n    private void replaceTaskCodeForConditionTaskParams(TaskDefinitionLog taskDefLog, Map<Long, Long> taskCodeMap) {\n        String taskParams = taskDefLog.getTaskParams();\n        ConditionsParameters params;\n\n        try {\n            params = JSONUtils.parseObject(taskParams, ConditionsParameters.class);\n        } catch (Exception e) {\n            log.warn(\"Invalid Condition task params: {}\", taskParams, e);\n            throw new IllegalArgumentException(\"Failed to parse Condition task params: \" + taskParams, e);\n        }\n\n        if (params == null) {\n            log.warn(\"Parsed Condition task params is null: {}\", taskParams);\n            throw new IllegalArgumentException(\"Failed to parse Condition task params: \" + taskParams);\n        }\n\n        // Update dependency task codes\n        ConditionsParameters.ConditionDependency dep = params.getDependence();\n        if (dep != null) {\n            for (ConditionDependentTaskModel taskModel : dep.getDependTaskList()) {\n                for (ConditionDependentItem item : taskModel.getDependItemList()) {\n                    Long oldCode = item.getDepTaskCode();\n                    if (taskCodeMap.containsKey(oldCode)) {\n                        item.setDepTaskCode(taskCodeMap.get(oldCode));\n                    }\n                }\n            }","sourceCodeStart":1485,"sourceCodeEnd":1521,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L1485-L1521","documentation":"Thrown by replaceTaskCodeForConditionTaskParams when the Condition task's taskParams JSON cannot be deserialized into ConditionsParameters (JSONUtils.parseObject threw). The raw params string is included in the message. Occurs while remapping dependency task codes during workflow copy/import; the operation aborts because Condition branches cannot be remapped from an unreadable params document.","triggerScenarios":"Copying/importing a workflow whose Condition task has malformed taskParams — invalid JSON, wrong types for dependence/conditionResult fields, or unexpected structure in dependTaskList.","commonSituations":"Definitions exported from older DolphinScheduler versions whose ConditionsParameters shape differs; hand-edited import JSON; direct DB edits to task_params.","solutions":["Inspect the malformed taskParams echoed in the error and fix the JSON structure (dependence, conditionResult with successNode/failedNode).","Open the Condition task in the UI and re-save its parameters to regenerate valid JSON.","Re-export from a source system running the same DolphinScheduler version, then re-import.","Validate the import file's task_params for all CONDITION task types before importing."],"exampleFix":"// before (taskParams)\n{\"dependence\": {\"dependTaskList\": [{\"dependItemList\": 42}]}}\n// after\n{\"dependence\": {\"dependTaskList\": [{\"dependItemList\": [{\"depTaskCode\": 111, \"depTaskVersion\": 1}]}]}, \"conditionResult\": {\"successNode\": [222], \"failedNode\": [333]}}","handlingStrategy":"validation","validationCode":"boolean validConditionParams(String taskParams) {\n    if (taskParams == null || taskParams.trim().isEmpty()) return false;\n    try {\n      return JSONUtils.parseObject(taskParams, ConditionsParameters.class) != null;\n    } catch (Exception e) { return false; }\n}\n// call for every CONDITIONS task before copy/import","typeGuard":"boolean isParsedConditionParams(String raw) {\n  try { return JSONUtils.parseObject(raw, ConditionsParameters.class) != null; }\n  catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    workflowDefinitionService.batchCopyWorkflowDefinition(...);\n} catch (ServiceException | IllegalArgumentException e) {\n    log.error(\"Copy failed, check Condition taskParams JSON\", e);\n}","preventionTips":["Re-export condition workflows when migrating between DolphinScheduler versions.","Validate dependTaskList/conditionResult structure in import files before importing.","Fix malformed task_params in the UI (re-save the Condition task) rather than patching JSON by hand."],"tags":["json","condition-task","workflow-copy","task-params"],"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"}