apache/dolphinscheduler · error · ServiceException
50037
50037
Error message
create task definition error
What it means
Thrown by createDagDefine when the task-definition save step (saveTaskDefine via TaskDefinitionServiceImpl/Dao) returns Constants.DEFINITION_FAILURE instead of success, meaning task definition logs could not be persisted while creating the workflow's DAG.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:288
workflowDefinition.setExecutionType(executionType);
return createDagDefine(loginUser, taskRelationList, workflowDefinition, taskDefinitionLogs);
}
protected WorkflowDefinition createDagDefine(User loginUser,
List<WorkflowTaskRelationLog> taskRelationList,
WorkflowDefinition workflowDefinition,
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("Save task definition error.");
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR);
}
int insertVersion =
processService.saveWorkflowDefine(loginUser, workflowDefinition, Boolean.TRUE, Boolean.TRUE);
if (insertVersion == 0) {
log.error("Save workflow definition error, workflowDefinitionCode:{}.", workflowDefinition.getCode());
throw new ServiceException(Status.CREATE_WORKFLOW_DEFINITION_ERROR);
}
log.info("Save workflow definition complete, workflowDefinitionCode:{}, workflowDefinitionVersion:{}.",
workflowDefinition.getCode(), insertVersion);
workflowDefinition.setVersion(insertVersion);
int insertResult = processService.saveTaskRelation(loginUser, workflowDefinition.getProjectCode(),
workflowDefinition.getCode(),
insertVersion, taskRelationList, taskDefinitionLogs, Boolean.TRUE);
if (insertResult != Constants.EXIT_CODE_SUCCESS) {
log.error(
"Save workflow task relations error, projectCode:{}, workflowDefinitionCode:{}, workflowDefinitionVersion:{}.",
workflowDefinition.getProjectCode(), workflowDefinition.getCode(), insertVersion);
throw new ServiceException(Status.CREATE_WORKFLOW_TASK_RELATION_ERROR);View on GitHub (pinned to 02eac45a1b)
Solutions
- Validate taskDefinitionJson parses and each taskDefinition has valid name/type/taskParams before calling the API.
- Check API server logs for the underlying exception inside saveTaskDefine to find the real cause (DB error vs bad params).
- Ensure the task plugin types used are installed on this DolphinScheduler version; upgrade plugins or change task types.
- Retry after fixing DB problems (space, duplicate keys, connectivity).
Example fix
// before: bad task params JSON
"taskDefinitionJson": "[{\"name\":\"a\",\"type\":\"SHELL\",\"taskParams\":{\"rawScript\":}] }"
// after: valid taskParams
"taskDefinitionJson": "[{\"name\":\"a\",\"type\":\"SHELL\",\"taskParams\":{\"rawScript\":\"echo hi\",\"resourceList\":[]}}]" Defensive patterns
Strategy: try-catch
Validate before calling
// client-side: verify each taskDefinition JSON parses and has required fields
for (TaskDefinition t : taskDefinitions) {
if (t.getName() == null || t.getType() == null || t.getTaskParams() == null) throw new IllegalArgumentException(t.getName());
} Try / catch
try {
workflowDefinitionService.createWorkflowDefinition(...);
} catch (ServiceException e) {
if (e.getCode() == 50037) { /* inspect logs for saveTaskDefine root cause */ }
else throw e;
} Prevention
- Validate taskDefinitionJson with the same DTOs the server uses before submitting.
- Keep task plugin versions aligned between API and worker servers.
- Watch database health (space, connections) during bulk workflow imports.
When it happens
Trigger: createWorkflowDefinition or doBatchOperateWorkflowDefinition generates taskDefinitionLogs whose persistence fails (invalid task JSON, DB insert error, constraint violation) leading saveTaskDefine to return DEFINITION_FAILURE.
Common situations: Malformed taskDefinitionJson in the API payload; task type plugin missing on the server; database issues (duplicate task definition code/version keys); importing workflows across incompatible versions.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/f594c1e7531ed9ac.
Report an issue: GitHub.