{"record":{"id":"80c73f6c310550a1","repo":"apache/dolphinscheduler","slug":"50003-80c73f","errorCode":"50003","errorMessage":"workflow definition {0} does not exist","messagePattern":"workflow 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":557,"sourceCode":"\n    /**\n     * query detail of workflow definition\n     *\n     * @param loginUser   login user\n     * @param projectCode project code\n     * @param code        workflow definition code\n     * @return workflow definition detail\n     */\n    @Override\n    public DagData queryWorkflowDefinitionByCode(User loginUser, long projectCode, long code) {\n        Project project = projectDao.queryByCode(projectCode);\n        // check user access for project\n        projectService.checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_DEFINITION);\n\n        WorkflowDefinition workflowDefinition = workflowDefinitionDao.queryByCode(code).orElse(null);\n        if (workflowDefinition == null || projectCode != workflowDefinition.getProjectCode()) {\n            log.error(\"workflow definition does not exist, workflowDefinitionCode:{}.\", code);\n            throw new ServiceException(Status.WORKFLOW_DEFINITION_NOT_EXIST, String.valueOf(code));\n        }\n        return processService.genDagData(workflowDefinition);\n    }\n\n    @Override\n    public Optional<WorkflowDefinition> queryWorkflowDefinition(long workflowDefinitionCode,\n                                                                int workflowDefinitionVersion) {\n        WorkflowDefinition workflowDefinition = workflowDefinitionDao.queryByCode(workflowDefinitionCode).orElse(null);\n        if (workflowDefinition == null || workflowDefinition.getVersion() != workflowDefinitionVersion) {\n            workflowDefinition = workflowDefinitionLogDao.queryByDefinitionCodeAndVersion(workflowDefinitionCode,\n                    workflowDefinitionVersion);\n        }\n        return Optional.ofNullable(workflowDefinition);\n    }\n\n    @Override\n    public WorkflowDefinition queryWorkflowDefinitionThrowExceptionIfNotFound(long workflowDefinitionCode,\n                                                                              int workflowDefinitionVersion) {","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L539-L575","documentation":"Thrown by queryWorkflowDefinitionByCode when no workflow definition exists with the given code, or when the found definition belongs to a different project than the projectCode path parameter. The API treats both cases as not-found to avoid leaking cross-project data.","triggerScenarios":"GET /projects/{projectCode}/workflow-definition/{code} with a wrong or deleted code, or a valid code that belongs to another projectCode.","commonSituations":"Stale cached workflow code after the workflow was deleted; copying a code between environments where codes differ; using the wrong projectCode in the URL path.","solutions":["Verify the workflow code via the workflow-definition list API for the given projectCode","Ensure the projectCode path segment matches the project that actually owns the workflow","Re-create the workflow if it was deleted (codes are not reusable)"],"exampleFix":"// before\nGET /projects/123/workflow-definition/99999999\n// after\nlist = GET /projects/123/workflow-definition/list  → find correct code → GET /projects/123/workflow-definition/{code}","handlingStrategy":"try-catch","validationCode":"Optional<WorkflowDefinition> def = workflowDefinitionDao.queryByCode(code);\nboolean usable = def.isPresent() && def.get().getProjectCode() == projectCode;","typeGuard":"static boolean workflowExistsInProject(WorkflowDefinition d, long projectCode) { return d != null && d.getProjectCode() == projectCode; }","tryCatchPattern":"try { return api.queryWorkflowDefinitionByCode(projectCode, code); } catch (ServiceException e) { if (e.getCode() == 50003) { /* re-list definitions to refresh codes */ } }","preventionTips":["Look up codes via the list API instead of hardcoding them","Confirm projectCode matches the workflow's owning project","Handle deleted workflows — codes are not reusable after deletion"],"tags":["api","not-found","workflow-definition","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"}