apache/dolphinscheduler · error · ServiceException
50038
50038
Error message
update task definition error
What it means
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.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:714
}
}
protected WorkflowDefinition updateDagDefine(User loginUser,
List<WorkflowTaskRelationLog> taskRelationList,
WorkflowDefinition workflowDefinition,
WorkflowDefinition workflowDefinitionDeepCopy,
List<TaskDefinitionLog> taskDefinitionLogs) {
taskDatasourcePermissionChecker.checkPermission(loginUser, taskDefinitionLogs);
taskSubWorkflowPermissionChecker.checkPermission(loginUser, taskDefinitionLogs);
int saveTaskResult = processService.saveTaskDefine(loginUser, workflowDefinition.getProjectCode(),
taskDefinitionLogs, Boolean.TRUE);
if (saveTaskResult == Constants.EXIT_CODE_SUCCESS) {
log.info("The task has not changed, so skip");
}
if (saveTaskResult == Constants.DEFINITION_FAILURE) {
log.error("Update task definitions error, projectCode:{}, workflowDefinitionCode:{}.",
workflowDefinition.getProjectCode(), workflowDefinition.getCode());
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);
}
boolean isChange = false;
if (workflowDefinition.equals(workflowDefinitionDeepCopy) && saveTaskResult == Constants.EXIT_CODE_SUCCESS) {
List<WorkflowTaskRelationLog> workflowTaskRelationLogList = workflowTaskRelationLogMapper
.queryByWorkflowCodeAndVersion(workflowDefinition.getCode(), workflowDefinition.getVersion());
if (taskRelationList.size() == workflowTaskRelationLogList.size()) {
Set<WorkflowTaskRelationLog> taskRelationSet = new HashSet<>(taskRelationList);
Set<WorkflowTaskRelationLog> workflowTaskRelationLogSet = new HashSet<>(workflowTaskRelationLogList);
if (taskRelationSet.size() == workflowTaskRelationLogSet.size()) {
taskRelationSet.removeAll(workflowTaskRelationLogSet);
if (!taskRelationSet.isEmpty()) {
isChange = true;
}
} else {
isChange = true;
}
} else {
isChange = true;View on GitHub (pinned to 02eac45a1b)
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
Example fix
// before
taskDefinitionJson = "[{...hand-written...}]"
// after
// fetch canonical definitions from an existing/exported workflow
String taskDefinitionJson = exportWorkflow(user, projectCode, code).getTaskDefinitionJson(); Defensive patterns
Strategy: try-catch
Validate before calling
// ensure every task code referenced exists and types are valid boolean allTasksValid = taskDefs.stream().allMatch(t -> t.getCode() > 0 && t.getVersion() > 0);
Try / catch
try { ... } catch (ServiceException e) { if (e.getCode() == 50038) { /* inspect taskDefinitionJson and server logs */ } } Prevention
- Generate taskDefinitionJson via export API, not by hand
- Keep task codes/versions consistent with the DB
- Validate task types against the current server version
When it happens
Trigger: updateWorkflowDefinition or doBatchOperateWorkflowDefinition supplying taskDefinitionJson that fails validation/persistence inside saveTaskDefineList (invalid task type, bad task code/version, relation referencing missing task).
Common situations: Hand-edited taskDefinitionJson, importing workflows across versions where task types changed, task relation referencing a deleted task definition.
Related errors
- 10107
- 50061
- Recover workflow instance failed: %s
- The workflow instance: %s status is %s, cannot repeat runnin
- Repeat running workflow instance failed: %s
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/7603ac00d0ec54eb.
Report an issue: GitHub.