{"record":{"id":"f410217f11c463be","repo":"flowable/flowable-engine","slug":"day-of-week-values-must-be-between-1-and-7","errorCode":null,"errorMessage":"Day-of-Week values must be between 1 and 7","messagePattern":"Day-of-Week values must be between 1 and 7","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java","lineNumber":738,"sourceCode":"        }\n    }\n\n    protected int checkNext(int pos, String s, int val, int type) throws ParseException {\n\n        int end = -1;\n        int i = pos;\n\n        if (i >= s.length()) {\n            addToSet(val, end, -1, type);\n            return i;\n        }\n\n        char c = s.charAt(pos);\n\n        if (c == 'L') {\n            if (type == DAY_OF_WEEK) {\n                if (val < 1 || val > 7) {\n                    throw new ParseException(\"Day-of-Week values must be between 1 and 7\", -1);\n                }\n                lastdayOfWeek = true;\n            } else {\n                throw new ParseException(\"'L' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            TreeSet<Integer> set = getSet(type);\n            set.add(val);\n            i++;\n            return i;\n        }\n\n        if (c == 'W') {\n            if (type == DAY_OF_MONTH) {\n                nearestWeekday = true;\n            } else {\n                throw new ParseException(\"'W' option is not valid here. (pos=\" + i + \")\", i);\n            }\n            if (val > 31) {","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java#L720-L756","documentation":"checkNext enforces that when the 'L' (last) option is used in the DAY_OF_WEEK field, the preceding value must be between 1 and 7. A value outside that range (or 0, which some dialects allow for Sunday) cannot denote a weekday for 'nL', so parsing fails.","triggerScenarios":"Expressions like \"0 0 0 ? * 0L\" or \"0 0 0 ? * 8L\" where the weekday qualifier before L is not 1-7.","commonSituations":"Porting cron expressions from systems where 0 = Sunday (e.g. standard Unix cron) into Quartz/Flowable, where Sunday is 7 or SUN.","solutions":["Replace 0 with 7 (or 'SUN') when targeting Sunday, e.g. \"? * 7L\" for last Sunday","Use weekday values 1-7 only, or names SUN-SAT","Pre-normalize expressions from Unix cron (0-based weekday) before passing to Flowable"],"exampleFix":"// before\nnew CronExpression(\"0 0 0 ? * 0L\");\n// after\nnew CronExpression(\"0 0 0 ? * 7L\"); // last Sunday","handlingStrategy":"validation","validationCode":"int normalizeDayOfWeek(int dow) {\n    if (dow == 0) return 7; // Unix-style 0=Sunday -> Quartz 7\n    if (dow < 1 || dow > 7) throw new IllegalArgumentException(\"Day-of-week must be 1-7\");\n    return dow;\n}","typeGuard":null,"tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(expr);\n} catch (ParseException e) {\n    if (e.getMessage().equals(\"Day-of-Week values must be between 1 and 7\")) {\n        throw new ConfigurationException(\"Use 1-7 (or SUN-SAT) for day-of-week, not 0: \" + expr, e);\n    }\n    throw e;\n}","preventionTips":["Convert Unix cron 0-based weekday values to Quartz 1-7 before parsing","Use weekday names (SUN, MON...) to avoid numeric ambiguity","Test L-option expressions with getNextValidTimeAfter"],"tags":["cron","day-of-week","quartz","l-option"],"backgroundTag":"value-out-of-range","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}