{"record":{"id":"7603ac00d0ec54eb","repo":"apache/dolphinscheduler","slug":"50038-7603ac","errorCode":"50038","errorMessage":"update task definition error","messagePattern":"update task definition error","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":714,"sourceCode":"        }\n    }\n\n    protected WorkflowDefinition updateDagDefine(User loginUser,\n                                                 List<WorkflowTaskRelationLog> taskRelationList,\n                                                 WorkflowDefinition workflowDefinition,\n                                                 WorkflowDefinition workflowDefinitionDeepCopy,\n                                                 List<TaskDefinitionLog> taskDefinitionLogs) {\n        taskDatasourcePermissionChecker.checkPermission(loginUser, taskDefinitionLogs);\n        taskSubWorkflowPermissionChecker.checkPermission(loginUser, taskDefinitionLogs);\n        int saveTaskResult = processService.saveTaskDefine(loginUser, workflowDefinition.getProjectCode(),\n                taskDefinitionLogs, Boolean.TRUE);\n        if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) {\n            log.info(\"The task has not changed, so skip\");\n        }\n        if (saveTaskResult == Constants.DEFINITION_FAILURE) {\n            log.error(\"Update task definitions error, projectCode:{}, workflowDefinitionCode:{}.\",\n                    workflowDefinition.getProjectCode(), workflowDefinition.getCode());\n            throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);\n        }\n        boolean isChange = false;\n        if (workflowDefinition.equals(workflowDefinitionDeepCopy) && saveTaskResult == Constants.EXIT_CODE_SUCCESS) {\n            List<WorkflowTaskRelationLog> workflowTaskRelationLogList = workflowTaskRelationLogMapper\n                    .queryByWorkflowCodeAndVersion(workflowDefinition.getCode(), workflowDefinition.getVersion());\n            if (taskRelationList.size() == workflowTaskRelationLogList.size()) {\n                Set<WorkflowTaskRelationLog> taskRelationSet = new HashSet<>(taskRelationList);\n                Set<WorkflowTaskRelationLog> workflowTaskRelationLogSet = new HashSet<>(workflowTaskRelationLogList);\n                if (taskRelationSet.size() == workflowTaskRelationLogSet.size()) {\n                    taskRelationSet.removeAll(workflowTaskRelationLogSet);\n                    if (!taskRelationSet.isEmpty()) {\n                        isChange = true;\n                    }\n                } else {\n                    isChange = true;\n                }\n            } else {\n                isChange = true;","sourceCodeStart":696,"sourceCodeEnd":732,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L696-L732","documentation":"Thrown when persisting the task definition list of a workflow fails during updateDagDefine (saveTaskResult == Constants.DEFINITION_FAILURE). The underlying task-definition save reported failure, aborting the workflow update.","triggerScenarios":"updateWorkflowDefinition or doBatchOperateWorkflowDefinition supplying taskDefinitionJson that fails validation/persistence inside saveTaskDefineList (invalid task type, bad task code/version, relation referencing missing task).","commonSituations":"Hand-edited taskDefinitionJson, importing workflows across versions where task types changed, task relation referencing a deleted task definition.","solutions":["Validate taskDefinitionJson structure and task types before the call","Regenerate the JSON from the current workflow via the export API","Ensure each task's code/version matches existing task definition logs","Check server logs for the underlying saveTaskDefineList failure cause"],"exampleFix":"// before\ntaskDefinitionJson = \"[{...hand-written...}]\"\n// after\n// fetch canonical definitions from an existing/exported workflow\nString taskDefinitionJson = exportWorkflow(user, projectCode, code).getTaskDefinitionJson();","handlingStrategy":"try-catch","validationCode":"// ensure every task code referenced exists and types are valid\nboolean allTasksValid = taskDefs.stream().allMatch(t -> t.getCode() > 0 && t.getVersion() > 0);","typeGuard":null,"tryCatchPattern":"try { ... } catch (ServiceException e) { if (e.getCode() == 50038) { /* inspect taskDefinitionJson and server logs */ } }","preventionTips":["Generate taskDefinitionJson via export API, not by hand","Keep task codes/versions consistent with the DB","Validate task types against the current server version"],"tags":["workflow","task-definition","persistence"],"backgroundTag":"database-write-failed","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"}