apache/dolphinscheduler · error · ServiceException

SCHEDULE_CRON_NOT_EXISTS

SCHEDULE_CRON_NOT_EXISTS

Error message

SCHEDULE_CRON_NOT_EXISTS: schedule of workflow definition {workflowDefinitionCode} does not exist

What it means

updateScheduleByWorkflowDefinitionCode looks up a Schedule row by workflowDefinitionCode; when scheduleDao.queryByWorkflowDefinitionCode returns null there is no schedule configured for that workflow, so the update is refused. This is a precondition check before any mutation.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java:436

                                                           long projectCode,
                                                           long workflowDefinitionCode,
                                                           String scheduleExpression,
                                                           WarningType warningType,
                                                           int warningGroupId,
                                                           FailureStrategy failureStrategy,
                                                           Priority workflowInstancePriority,
                                                           String workerGroup,
                                                           String tenantCode,
                                                           long environmentCode) {
        Project project = projectDao.queryByCode(projectCode);
        projectService.checkHasProjectWritePermissionThrowException(loginUser, project);

        // check schedule exists
        Schedule schedule = scheduleDao.queryByWorkflowDefinitionCode(workflowDefinitionCode);
        if (schedule == null) {
            log.error("Schedule of workflow definition does not exist, workflowDefinitionCode:{}.",
                    workflowDefinitionCode);
            throw new ServiceException(Status.SCHEDULE_CRON_NOT_EXISTS, workflowDefinitionCode);
        }

        WorkflowDefinition workflowDefinition = workflowDefinitionDao.queryByCode(workflowDefinitionCode).orElse(null);
        if (workflowDefinition == null || projectCode != workflowDefinition.getProjectCode()) {
            log.error("workflow definition does not exist, workflowDefinitionCode:{}.", workflowDefinitionCode);
            throw new ServiceException(Status.WORKFLOW_DEFINITION_NOT_EXIST,
                    String.valueOf(workflowDefinitionCode));
        }

        return updateSchedule(schedule, workflowDefinition, scheduleExpression, warningType, warningGroupId,
                failureStrategy, workflowInstancePriority, workerGroup, tenantCode, environmentCode);
    }

    @Transactional
    @Override
    public void onlineScheduler(User loginUser, Long projectCode, Integer schedulerId) {
        projectService.checkHasProjectWritePermissionThrowException(loginUser, projectCode);
        Schedule schedule = scheduleDao.queryById(schedulerId);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Create the schedule first (SchedulerService.createSchedule) for the workflow definition code, then update it.
  2. Verify the workflowDefinitionCode exists in t_ds_workflow_definition and has a matching row in the schedule table.
  3. Check the correct code (long code, not the numeric id) is passed.
  4. Query the schedule via the API before updating to confirm existence.
Defensive patterns

Strategy: validation

Validate before calling

Schedule existing = scheduleDao.queryByWorkflowDefinitionCode(workflowDefinitionCode);
if (existing == null) {
    throw new IllegalStateException("No schedule for workflow code " + workflowDefinitionCode);
}

Try / catch

try {
    schedulerService.updateScheduleByWorkflowDefinitionCode(loginUser, projectCode, code, ...);
} catch (ServiceException e) {
    if (e.getCode() == Status.SCHEDULE_CRON_NOT_EXISTS.getCode()) {
        // create the schedule first or fail the pipeline with a clear message
    }
}

Prevention

When it happens

Trigger: Calling updateScheduleByWorkflowDefinitionCode with a workflowDefinitionCode that has never had a schedule created (createSchedule never called, or schedule deleted), or with a mistyped/non-existent code.

Common situations: Automation scripts updating schedules right after creating a workflow definition but before creating the schedule; using the workflow definition id instead of code; schedule removed by another user/process.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/bf6b668aafcd32b1. Report an issue: GitHub.