{"record":{"id":"7c0108d72c788a2a","repo":"apache/dolphinscheduler","slug":"parse-to-cron-expression-error","errorCode":"PARSE_TO_CRON_EXPRESSION_ERROR","errorMessage":"PARSE_TO_CRON_EXPRESSION_ERROR: parse to cron expression error","messagePattern":"PARSE_TO_CRON_EXPRESSION_ERROR: parse to cron expression error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java","lineNumber":393,"sourceCode":"     * @return the next five fire time\n     */\n    @Override\n    public List<String> previewSchedule(User loginUser, String schedule) {\n        Cron cron;\n        ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);\n\n        assert scheduleParam != null;\n        ZoneId zoneId = TimeZone.getTimeZone(scheduleParam.getTimezoneId()).toZoneId();\n        ZonedDateTime now = ZonedDateTime.now(zoneId);\n        ZonedDateTime startTime = ZonedDateTime.ofInstant(scheduleParam.getStartTime().toInstant(), zoneId);\n        ZonedDateTime endTime = ZonedDateTime.ofInstant(scheduleParam.getEndTime().toInstant(), zoneId);\n        startTime = now.isAfter(startTime) ? now : startTime;\n\n        try {\n            cron = CronUtils.parse2Cron(scheduleParam.getCrontab());\n        } catch (CronParseException e) {\n            log.error(\"Parse cron to cron expression error, crontab:{}.\", scheduleParam.getCrontab(), e);\n            throw new ServiceException(Status.PARSE_TO_CRON_EXPRESSION_ERROR);\n        }\n        List<ZonedDateTime> selfFireDateList =\n                CronUtils.getSelfFireDateList(startTime, endTime, cron, Constants.PREVIEW_SCHEDULE_EXECUTE_COUNT);\n        return selfFireDateList.stream()\n                .map(t -> DateUtils.dateToString(t, zoneId))\n                .collect(Collectors.toList());\n    }\n\n    /**\n     * update workflow definition schedule\n     *\n     * @param loginUser               login user\n     * @param projectCode             project code\n     * @param workflowDefinitionCode   workflow definition code\n     * @param scheduleExpression      scheduleExpression\n     * @param warningType             warning type\n     * @param warningGroupId          warning group id\n     * @param failureStrategy         failure strategy","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java#L375-L411","documentation":"previewSchedule could not parse the provided crontab string into a valid Quartz Cron expression via CronUtils.parse2Cron. The crontab string in the ScheduleParam is malformed or uses an unsupported cron syntax. The API rejects it so callers get a structured status instead of a raw CronParseException.","triggerScenarios":"Calling the schedule preview API (previewSchedule) with a `crontab` field that fails Quartz cron parsing: wrong field count, invalid characters, out-of-range values, or non-standard syntax (e.g. @daily, 5-character POSIX crons).","commonSituations":"Users pasting Linux/Unix crontab syntax into DolphinScheduler, typos like '0 0 * *' (missing field), seconds field forgotten (Quartz needs 6-7 fields like '0 0 12 * * ?'), or frontend submitting an empty crontab.","solutions":["Fix the crontab to valid Quartz syntax: 6-7 fields, e.g. '0 0 12 * * ?' (seconds minutes hours dayOfMonth month dayOfWeek [year]).","Use '?' instead of '*' in dayOfMonth or dayOfWeek when the other is specified.","Validate locally with CronUtils.isValidExpression(crontab) or an online Quartz cron validator before calling the preview API.","If migrating from Unix cron, convert 5-field expressions to Quartz format first."],"exampleFix":"// before\nScheduleParam p = new ScheduleParam();\np.setCrontab(\"0 12 * *\");            // 5 fields, invalid for Quartz\n\n// after\np.setCrontab(\"0 0 12 * * ?\");        // valid Quartz expression","handlingStrategy":"validation","validationCode":"if (!CronUtils.isValidExpression(scheduleParam.getCrontab())) {\n    throw new IllegalArgumentException(\"Invalid Quartz crontab: \" + scheduleParam.getCrontab());\n}","typeGuard":null,"tryCatchPattern":"try {\n    schedulerService.previewSchedule(loginUser, projectCode, scheduleParam, precision);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.PARSE_TO_CRON_EXPRESSION_ERROR.getCode()) {\n        // surface a field-level message for crontab\n    }\n}","preventionTips":["Always validate crontab with CronUtils.isValidExpression before API calls","Remember Quartz requires 6-7 fields (seconds first)","Use '?' for dayOfMonth/dayOfWeek mutual exclusion","Build cron strings via a cron-builder library rather than string concatenation"],"tags":["cron","validation","quartz","scheduler"],"backgroundTag":"invalid-regex-pattern","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"}