flowable/flowable-engine · error · ParseException
Invalid Day-of-Week value: '
Error message
Invalid Day-of-Week value: '
What it means
Thrown by storeExpressionVals when parsing the Day-of-Week field of a cron expression: getDayOfWeekNumber(sub) returned < 0, meaning the 3-letter token (e.g. 'MON', 'FRI') or name at position i is not a recognized day-of-week. The library only accepts SUN-SAT (0-7, or 1-7 mapping), 3-letter abbreviations, and numeric values in this position. Any unrecognized token in the Day-of-Week slot is rejected with this ParseException.
Source
Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/calendar/CronExpression.java:575
sval = getMonthNumber(sub) + 1;
if (sval <= 0) {
throw new ParseException("Invalid Month value: '" + sub + "'", i);
}
if (s.length() > i + 3) {
c = s.charAt(i + 3);
if (c == '-') {
i += 4;
sub = s.substring(i, i + 3);
eval = getMonthNumber(sub) + 1;
if (eval <= 0) {
throw new ParseException("Invalid Month value: '" + sub + "'", i);
}
}
}
} else if (type == DAY_OF_WEEK) {
sval = getDayOfWeekNumber(sub);
if (sval < 0) {
throw new ParseException("Invalid Day-of-Week value: '" + sub + "'", i);
}
if (s.length() > i + 3) {
c = s.charAt(i + 3);
if (c == '-') {
i += 4;
sub = s.substring(i, i + 3);
eval = getDayOfWeekNumber(sub);
if (eval < 0) {
throw new ParseException("Invalid Day-of-Week value: '" + sub + "'", i);
}
} else if (c == '#') {
try {
i += 4;
nthdayOfWeek = Integer.parseInt(s.substring(i));
if (nthdayOfWeek < 1 || nthdayOfWeek > 5) {
throw new Exception();
}
} catch (Exception e) {View on GitHub (pinned to d6d39ce1c6)
Solutions
- Check the Day-of-Week field token: use only SUN, MON, TUE, WED, THU, FRI, SAT (uppercase 3-letter) or numbers 1-7 (or 0-7 where 0/7=SUN).
- Verify the expression has the correct number of fields (6 or 7 for Quartz/Flowable: sec min hour day-of-month month day-of-week [year]); a missing field shifts day names into the wrong slot.
- Replace '?' or '*' if the field is intentionally 'any day' and the token is garbage.
- Call CronExpression.validateExpression(cronExpr) at application startup to fail fast on misconfigured schedules.
Example fix
// before
new CronExpression("0 0 12 ? * Monday");
// after
new CronExpression("0 0 12 ? * MON"); Defensive patterns
Strategy: validation
Validate before calling
private static final java.util.regex.Pattern DOW_TOKEN = java.util.regex.Pattern.compile("^(MON|TUE|WED|THU|FRI|SAT|SUN|[0-7])(-([0-7]|MON|TUE|WED|THU|FRI|SAT|SUN))?$");
// before calling new CronExpression(expr): check field 6 against DOW_TOKEN Try / catch
try {
new CronExpression(expr);
} catch (java.text.ParseException e) {
throw new IllegalArgumentException("Invalid cron Day-of-Week field: " + e.getMessage(), e);
} Prevention
- Use only 3-letter uppercase day abbreviations (SUN-SAT) or numbers 1-7
- Keep the 6/7-field Quartz cron layout (sec min hour dom month dow [year])
- Run CronExpression.validateExpression on all schedules at startup
When it happens
Trigger: Calling new CronExpression(expr) or validateExpression(expr) where the 6th/7th field contains a token that getDayOfWeekNumber cannot resolve, e.g. a misspelled day name ('SND', 'WEDNESDAY' full name), a number out of range like '8' or '0' if unsupported, or a shifted field position where Day-of-Month tokens land in the Day-of-Week slot.
Common situations: Hand-written cron strings with full day names ('Monday') instead of 3-letter abbreviations; expressions copied from Unix crontab with 5 fields pasted into a 6/7-field Quartz-style parser causing field misalignment; typos like 'MNO'; locale-specific day abbreviations.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Failed to parse scheduler expression:
- A numeric value between 1 and 5 must follow the '#' option
- Illegal characters for this position: '
- Illegal character after ?:
- '?' can only be specified for Day-of-Month or Day-of-Week.
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/4470aa93617fc684.
Report an issue: GitHub.