{"record":{"id":"7b37dd8863065349","repo":"apache/dolphinscheduler","slug":"50036","errorCode":"50036","errorMessage":"check workflow task relation error","messagePattern":"check workflow task relation error","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":428,"sourceCode":"                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;\n        } catch (Exception e) {\n            log.error(\"Check task relation list error, meet an unknown exception, given taskRelationJson: {}\",\n                    taskRelationJson, e);\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR);\n        }\n    }\n\n    /**\n     * query workflow definition list\n     *\n     * @param loginUser   login user\n     * @param projectCode project code\n     * @return definition list","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L410-L446","documentation":"Thrown when any WorkflowTaskRelationLog in taskRelationJson has a postTaskCode of 0, meaning the relation's downstream task is unset. Only preTaskCode may be 0 (marking the workflow's entry relation), so a zero post-task makes the relation invalid.","triggerScenarios":"updateWorkflowDefinition/importWorkflowDefinition with a relation entry where postTaskCode=0 — typically a partially initialized or truncated relation object.","commonSituations":"Hand-constructing relations JSON and leaving postTaskCode defaulted to 0; copy-pasting the entry relation (pre=0) and swapping fields; JSON tooling that drops numeric fields equal to 0.","solutions":["Set postTaskCode to the actual task code of the downstream task for every relation entry","Remove any relation entry that has no real downstream task","Regenerate relation JSON from the saved workflow to get correct codes"],"exampleFix":"// before\n{\"preTaskCode\":123,\"postTaskCode\":0,...}\n// after\n{\"preTaskCode\":123,\"postTaskCode\":456,\"postTaskVersion\":1}","handlingStrategy":"validation","validationCode":"boolean hasZeroPost = relations.stream().anyMatch(r -> r.getPostTaskCode() == 0);\nif (hasZeroPost) throw new IllegalArgumentException(\"postTaskCode cannot be 0\");","typeGuard":null,"tryCatchPattern":"try { ... } catch (ServiceException e) { if (e.getCode() == 50036) { /* scan relations for postTaskCode==0 */ } }","preventionTips":["Only preTaskCode may be 0 (entry relation)","Check that JSON tooling doesn't drop or default numeric fields","Copy relation templates carefully — don't swap pre/post"],"tags":["api","validation","task-relation","dolphinscheduler"],"backgroundTag":"empty-required-field","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"}