{"record":{"id":"4475a1993d8f9fbb","repo":"alibaba/spring-cloud-alibaba","slug":"invalid-day-of-week-value","errorCode":null,"errorMessage":"Invalid Day-of-Week value: '{}'","messagePattern":"Invalid Day-of-Week value: '(.+?)'","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java","lineNumber":350,"sourceCode":"\t\t\tString sub = s.substring(i, i + 3);\n\t\t\tint sval = -1;\n\t\t\tint eval = -1;\n\t\t\tif (type == MONTH) {\n\t\t\t\tsval = getMonthNumber(sub) + 1;\n\t\t\t\tif (sval <= 0) {\n\t\t\t\t\tthrow new ParseException(\"Invalid Month value: '\" + sub + \"'\", i);\n\t\t\t\t}\n\t\t\t\tif (s.length() > i + 3 && (s.charAt(i + 3) == '-')) {\n\t\t\t\t\ti += 4;\n\t\t\t\t\tsub = s.substring(i, i + 3);\n\t\t\t\t\teval = getMonthNumber(sub) + 1;\n\t\t\t\t\tAssert.isTrue(eval > 0, \"Invalid Month value: '\" + sub + \"'\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (type == DAY_OF_WEEK) {\n\t\t\t\tsval = getDayOfWeekNumber(sub);\n\t\t\t\tif (sval < 0) {\n\t\t\t\t\tthrow new ParseException(\"Invalid Day-of-Week value: '\"\n\t\t\t\t\t\t\t+ sub + \"'\", i);\n\t\t\t\t}\n\t\t\t\tif (s.length() > i + 3) {\n\t\t\t\t\tc = s.charAt(i + 3);\n\t\t\t\t\tif (c == '-') {\n\t\t\t\t\t\ti += 4;\n\t\t\t\t\t\tsub = s.substring(i, i + 3);\n\t\t\t\t\t\teval = getDayOfWeekNumber(sub);\n\t\t\t\t\t\tAssert.isTrue(eval >= 0, \"Invalid Day-of-Week value: '\" + sub + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\telse if (c == '#') {\n\t\t\t\t\t\ti += 4;\n\t\t\t\t\t\tnthdayOfWeek = Integer.parseInt(s.substring(i));\n\t\t\t\t\t\tAssert.isTrue(nthdayOfWeek > 0 && nthdayOfWeek < 6, \"A numeric value between 1 and 5 must follow the '#' option\");\n\t\t\t\t\t}\n\t\t\t\t\telse if (c == 'L') {\n\t\t\t\t\t\tlastdayOfWeek = true;\n\t\t\t\t\t\ti++;","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java#L332-L368","documentation":"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>\\''.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (typo)\n0 0 0 ? * WDN\n\n# after\n0 0 0 ? * WED","handlingStrategy":"try-catch","validationCode":"static String validateCron(String cron) throws ParseException {\n    new com.alibaba.cloud.scheduling.schedulerx.util.CronExpression(cron);\n    return cron;\n}","typeGuard":"static final java.util.Set<String> DOW = java.util.Set.of(\n    \"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\");\nstatic boolean validDowToken(String t) {\n    return DOW.contains(t) || t.matches(\"[0-9#L]/?[^ ]*\");\n}","tryCatchPattern":"try {\n    new CronExpression(cron);\n} catch (ParseException e) {\n    // \"Invalid Day-of-Week value: 'WDN'\"\n    log.error(\"Bad day-of-week in cron '{}': {}\", cron, e.getMessage());\n}","preventionTips":["Use numeric 1-7 for weekdays to avoid abbreviation typos (note 1=SUN in Quartz).","Ensure no double spaces inside the expression."],"tags":["java","schedulerx","cron","parsing","validation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}