{"record":{"id":"fc807cfff4eef499","repo":"apache/dolphinscheduler","slug":"workflow-definition-not-exist-fc807c","errorCode":"WORKFLOW_DEFINITION_NOT_EXIST","errorMessage":"WORKFLOW_DEFINITION_NOT_EXIST: workflow definition {workflowDefinitionCode} does not exist","messagePattern":"WORKFLOW_DEFINITION_NOT_EXIST: workflow definition (.+?) does not exist","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java","lineNumber":203,"sourceCode":"        scheduleObj.setWorkerGroup(workerGroup);\n        scheduleObj.setEnvironmentCode(environmentCode);\n        scheduleDao.insert(scheduleObj);\n\n        /**\n         * updateWorkflowInstance receivers and cc by workflow definition id\n         */\n        workflowDefinition.setWarningGroupId(warningGroupId);\n        workflowDefinitionDao.updateById(workflowDefinition);\n\n        log.info(\"Schedule create complete, projectCode:{}, workflowDefinitionCode:{}, scheduleId:{}.\",\n                projectCode, workflowDefinitionCode, scheduleObj.getId());\n        return scheduleDao.queryById(scheduleObj.getId());\n    }\n\n    protected void projectPermCheckByWorkflowCode(User loginUser, long workflowDefinitionCode) {\n        WorkflowDefinition workflowDefinition = workflowDefinitionDao.queryByCode(workflowDefinitionCode).orElse(null);\n        if (workflowDefinition == null) {\n            throw new ServiceException(Status.WORKFLOW_DEFINITION_NOT_EXIST, workflowDefinitionCode);\n        }\n        Project project = projectDao.queryByCode(workflowDefinition.getProjectCode());\n        this.projectService.checkHasProjectWritePermissionThrowException(loginUser, project);\n    }\n\n    /**\n     * updateWorkflowInstance schedule\n     *\n     * @param loginUser               login user\n     * @param projectCode             project code\n     * @param id                      scheduler id\n     * @param scheduleExpression      scheduler\n     * @param warningType             warning type\n     * @param warningGroupId          warning group id\n     * @param failureStrategy         failure strategy\n     * @param workerGroup             worker group\n     * @param tenantCode              tenant code\n     * @param environmentCode         environment code","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java#L185-L221","documentation":"WORKFLOW_DEFINITION_NOT_EXIST is thrown by projectPermCheckByWorkflowCode (which deleteSchedulesById calls) when workflowDefinitionDao.queryByCode() finds no workflow definition for the given code. This means the schedule points at a workflow that no longer exists, so permission/project checks cannot proceed and the delete is aborted.","triggerScenarios":"DELETE /projects/{projectCode}/schedules/{scheduleId} where the schedule's workflowDefinitionCode references a workflow that was deleted (or whose code is wrong/stale). Since deleteSchedulesById first loads the schedule by id, this fires only when the schedule row survives but its workflow row does not.","commonSituations":"Orphaned schedule rows left after a workflow was deleted in an older version or via direct DB manipulation; copying schedule definitions across environments where workflow codes differ; using an outdated cached workflow code in automation scripts.","solutions":["Confirm the workflow exists: GET /projects/{projectCode}/workflow-definition/{code} or query t_ds_workflow_definition by code.","Delete the orphaned schedule directly or recreate the workflow under the expected code before retrying.","Check the projectCode in the URL matches the project that actually owns the workflow the schedule references."],"exampleFix":"// before\ncurl -X DELETE '/projects/1/schedules/55'   // workflow behind schedule 55 was deleted\n// after\n// recreate workflow or remove orphan schedule row, then retry with a valid schedule/workflow pair\ncurl -X DELETE '/projects/1/schedules/56'","handlingStrategy":"validation","validationCode":"WorkflowDefinition wf = workflowDefinitionDao.queryByCode(code).orElse(null);\nif (wf == null) {\n    throw new IllegalStateException(\"Workflow \" + code + \" does not exist; cannot operate on its schedules\");\n}","typeGuard":null,"tryCatchPattern":"try { schedulerService.deleteSchedulesById(user, scheduleId); } catch (ServiceException e) { if (e.getCode() == Status.WORKFLOW_DEFINITION_NOT_EXIST) { /* schedule is orphaned; clean up row or recreate workflow */ } }","preventionTips":["Delete a workflow's schedules before deleting the workflow","Avoid direct DB manipulation that leaves schedule rows orphaned","Re-derive workflow codes per environment instead of hardcoding them"],"tags":["scheduler","workflow-not-found","orphaned-record"],"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-14T05:17:10.506Z"}