{"record":{"id":"1d875cd80f35adbb","repo":"apache/dolphinscheduler","slug":"50030-1d875c","errorCode":"50030","errorMessage":"task definition [{0}] does not exist","messagePattern":"task definition \\[(.+?)\\] does not exist","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":415,"sourceCode":"                log.error(\"Generate task relation list failed the taskRelation list is empty, taskRelationJson: {}\",\n                        taskRelationJson);\n                throw new ServiceException(Status.DATA_IS_NOT_VALID);\n            }\n            List<WorkflowTaskRelation> workflowTaskRelations = taskRelationList.stream()\n                    .map(workflowTaskRelationLog -> JSONUtils.parseObject(\n                            JSONUtils.toJsonString(workflowTaskRelationLog),\n                            WorkflowTaskRelation.class))\n                    .collect(Collectors.toList());\n            List<TaskNode> taskNodeList = processService.transformTask(workflowTaskRelations, taskDefinitionLogs);\n            if (taskNodeList.size() != taskRelationList.size()) {\n                Set<Long> postTaskCodes = taskRelationList.stream().map(WorkflowTaskRelationLog::getPostTaskCode)\n                        .collect(Collectors.toSet());\n                Set<Long> taskNodeCodes = taskNodeList.stream().map(TaskNode::getCode).collect(Collectors.toSet());\n                Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes);\n                if (CollectionUtils.isNotEmpty(codes)) {\n                    String taskCodes = StringUtils.join(codes, Constants.COMMA);\n                    log.error(\"Task definitions do not exist, taskCodes:{}.\", taskCodes);\n                    throw new ServiceException(Status.TASK_DEFINE_NOT_EXIST, taskCodes);\n                }\n            }\n            if (graphHasCycle(taskNodeList)) {\n                log.error(\"workflow DAG has cycle.\");\n                throw new ServiceException(Status.WORKFLOW_NODE_HAS_CYCLE);\n            }\n\n            // check whether the task relation json is normal\n            for (WorkflowTaskRelationLog workflowTaskRelationLog : taskRelationList) {\n                if (workflowTaskRelationLog.getPostTaskCode() == 0) {\n                    log.error(\"The post_task_code or post_task_version of workflowTaskRelationLog can not be zero, \" +\n                            \"workflowTaskRelationLogId:{}.\", workflowTaskRelationLog.getId());\n                    throw new ServiceException(Status.CHECK_WORKFLOW_TASK_RELATION_ERROR);\n                }\n            }\n            return taskRelationList;\n        } catch (ServiceException ex) {\n            throw ex;","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L397-L433","documentation":"Thrown when task relations reference postTaskCode values that have no matching task definition in the submitted taskDefinitionJson. The code computes the set difference between relation post-codes and task-node codes and rejects the request listing the missing codes.","triggerScenarios":"updateWorkflowDefinition/importWorkflowDefinition where taskRelationJson mentions a task code absent from taskDefinitionJson — e.g. a relation kept for a deleted task, or codes copied from a different workflow.","commonSituations":"Deleting a task in the UI but exporting stale relation JSON; editing JSON manually and forgetting to remove the relation of a removed task; merging workflows so codes no longer line up.","solutions":["Add a task definition with the reported missing code to taskDefinitionJson","Remove or fix the relation entries referencing the missing task codes","Regenerate both JSONs together from the workflow designer so codes stay consistent"],"exampleFix":"// before\nrelations contain postTaskCode=111 but no definition with code 111\n// after\neither add {\"code\":111,...} to taskDefinitionJson or delete the relation with postTaskCode=111","handlingStrategy":"validation","validationCode":"Set<Long> defCodes = defs.stream().map(TaskDefinitionLog::getCode).collect(Collectors.toSet());\nList<Long> missing = relations.stream().map(WorkflowTaskRelationLog::getPostTaskCode).filter(c -> !defCodes.contains(c)).collect(Collectors.toList());\nif (!missing.isEmpty()) throw new IllegalArgumentException(\"missing task definitions: \" + missing);","typeGuard":null,"tryCatchPattern":"try { ... } catch (ServiceException e) { if (e.getCode() == 50030) { /* e.getMessage() lists missing codes; fix relations or add defs */ } }","preventionTips":["Keep relation and definition JSON generated together from one source","Remove relations when deleting a task","Cross-check codes after merging workflows"],"tags":["api","consistency","task-relation","dolphinscheduler"],"backgroundTag":"entity-not-found","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"}