alibaba/spring-cloud-alibaba · error · ParseException
Invalid Day-of-Week value: '{}'
Error message
Invalid Day-of-Week value: '{}' What it means
Thrown in storeExpressionVals while parsing the DAY_OF_WEEK field: when a token starts with a letter, getDayOfWeekNumber(sub) returns -1 because the 3-letter abbreviation is unrecognised (SUN,MON,TUE,WED,THU,FRI,SAT). The parser throws ParseException 'Invalid Day-of-Week value: \'<sub>\''.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:350
String sub = s.substring(i, i + 3);
int sval = -1;
int eval = -1;
if (type == MONTH) {
sval = getMonthNumber(sub) + 1;
if (sval <= 0) {
throw new ParseException("Invalid Month value: '" + sub + "'", i);
}
if (s.length() > i + 3 && (s.charAt(i + 3) == '-')) {
i += 4;
sub = s.substring(i, i + 3);
eval = getMonthNumber(sub) + 1;
Assert.isTrue(eval > 0, "Invalid Month value: '" + sub + "'");
}
}
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);
Assert.isTrue(eval >= 0, "Invalid Day-of-Week value: '" + sub + "'");
}
else if (c == '#') {
i += 4;
nthdayOfWeek = Integer.parseInt(s.substring(i));
Assert.isTrue(nthdayOfWeek > 0 && nthdayOfWeek < 6, "A numeric value between 1 and 5 must follow the '#' option");
}
else if (c == 'L') {
lastdayOfWeek = true;
i++;View on GitHub (pinned to 115d590110)
Solutions
- Use a valid three-letter weekday abbreviation (SUN,MON,TUE,WED,THU,FRI,SAT) or numeric 1-7 (1=SUN in Quartz).
- Remove stray spaces/tabs inside the field; the tokenizer splits on whitespace so each field must be a single token.
- Validate at config load.
Example fix
# before (typo) 0 0 0 ? * WDN # after 0 0 0 ? * WED
Defensive patterns
Strategy: try-catch
Validate before calling
static String validateCron(String cron) throws ParseException {
new com.alibaba.cloud.scheduling.schedulerx.util.CronExpression(cron);
return cron;
} Type guard
static final java.util.Set<String> DOW = java.util.Set.of(
"SUN","MON","TUE","WED","THU","FRI","SAT");
static boolean validDowToken(String t) {
return DOW.contains(t) || t.matches("[0-9#L]/?[^ ]*");
} Try / catch
try {
new CronExpression(cron);
} catch (ParseException e) {
// "Invalid Day-of-Week value: 'WDN'"
log.error("Bad day-of-week in cron '{}': {}", cron, e.getMessage());
} Prevention
- Use numeric 1-7 for weekdays to avoid abbreviation typos (note 1=SUN in Quartz).
- Ensure no double spaces inside the expression.
When it happens
Trigger: A day-of-week field with an unrecognised 3-letter token, e.g. '0 0 0 ? * XYZ' or '0 0 0 ? * WED ' with a stray space making a bad substring. The check at CronExpression.java:349-352 fires when sval < 0.
Common situations: Typo in a weekday abbreviation; using 'WEDNESDAY' instead of 'WED'; a numeric value out of the 1-7 range when mixed; extra whitespace producing a wrong 3-char substring.
Related errors
- Support for specifying 'L' and 'LW' with other days of the m
- Support for specifying 'L' with other days of the week is no
- Support for specifying multiple "nth" days is not implemente
- Unexpected end of expression.
- Support for specifying both a day-of-week AND a day-of-month
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/4475a1993d8f9fbb.
Report an issue: GitHub.