{"record":{"id":"65e02e047e6c693c","repo":"jeecgboot/JeecgBoot","slug":"invalid-day-of-week-value-sub","errorCode":null,"errorMessage":"Invalid Day-of-Week value: '{sub}'","messagePattern":"Invalid Day-of-Week value: '(.+?)'","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java","lineNumber":568,"sourceCode":"                sval = getMonthNumber(sub) + 1;\n                if (sval <= 0) {\n                    throw new ParseException(\"Invalid Month value: '\" + sub + \"'\", i);\n                }\n                if (s.length() > i + 3) {\n                    c = s.charAt(i + 3);\n                    if (c == '-') {\n                        i += 4;\n                        sub = s.substring(i, i + 3);\n                        eval = getMonthNumber(sub) + 1;\n                        if (eval <= 0) {\n                            throw new ParseException(\"Invalid Month value: '\" + sub + \"'\", i);\n                        }\n                    }\n                }\n            } else if (type == DAY_OF_WEEK) {\n                sval = getDayOfWeekNumber(sub);\n                if (sval < 0) {\n                    throw new ParseException(\"Invalid Day-of-Week value: '\"\n                            + sub + \"'\", i);\n                }\n                if (s.length() > i + 3) {\n                    c = s.charAt(i + 3);\n                    if (c == '-') {\n                        i += 4;\n                        sub = s.substring(i, i + 3);\n                        eval = getDayOfWeekNumber(sub);\n                        if (eval < 0) {\n                            throw new ParseException(\n                                    \"Invalid Day-of-Week value: '\" + sub\n                                            + \"'\", i);\n                        }\n                    } else if (c == '#') {\n                        try {\n                            i += 4;\n                            nthDayOfWeek = Integer.parseInt(s.substring(i));\n                            if (nthDayOfWeek < 1 || nthDayOfWeek > 5) {","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-xxljob/src/main/java/com/xxl/job/admin/business/scheduler/cron/CronExpression.java#L550-L586","documentation":"In the DAY_OF_WEEK branch, the parser reads a 3-char alpha substring and calls getDayOfWeekNumber(sub). If it returns < 0 the token is not a recognized weekday abbreviation. Only SUN, MON, TUE, WED, THU, FRI, SAT are accepted. This guards the start token of a day-of-week expression.","triggerScenarios":"Day-of-week field with an unknown alpha token, e.g. '0 0 0 ? * MND' (typo), '0 0 0 ? * MO' (truncated to 2 letters so the slice is bad), or '0 0 0 ? * Monday' (full name, slice 'Mon' may pass getDayOfWeekNumber only if case-insensitive - but here the branch requires uppercase A-Z and the lookup is case-folded; a stray non-matching slice still fails).","commonSituations":"Misspelled weekday abbreviations; using full day names; truncation when the dow field is built from a substring; locale assumptions about day names.","solutions":["Use a valid 3-letter weekday code: SUN, MON, TUE, WED, THU, FRI, SAT.","Prefer numeric day-of-week (1=SUN..7=SAT in this Quartz variant) to avoid abbreviation errors.","Ensure the token is exactly 3 uppercase letters - the parser slices substring(i, i+3).","For lists/ranges validate each element against the accepted set before submission."],"exampleFix":"// before - misspelled weekday\nString cron = \"0 0 0 ? * MND\";  // Invalid Day-of-Week value: 'MND'\n\n// after - valid abbreviation or numeric\nString cron = \"0 0 0 ? * MON\";\n// or numeric (1=SUN..7=SAT)\nString cron = \"0 0 0 ? * 2\";","handlingStrategy":"validation","validationCode":"private static final java.util.Set<String> DOW =\n    java.util.Set.of(\"SUN\",\"MON\",\"TUE\",\"WED\",\"THU\",\"FRI\",\"SAT\");\n\n// Validate a DAY_OF_WEEK field token before parsing.\npublic static String validateDowField(String field) {\n    for (String part : field.split(\"[,#]\")) {\n        for (String end : part.split(\"-\")) {\n            String t = end.trim().toUpperCase().replaceAll(\"L$|W$\", \"\");\n            if (t.equals(\"*\") || t.equals(\"?\") || t.matches(\"\\\\d+\") || t.matches(\"\\\\d+L\")) continue;\n            if (!DOW.contains(t)) return \"invalid day-of-week token: \" + end;\n        }\n    }\n    return null;\n}","typeGuard":"public static boolean isValidDowToken(String token) {\n    String t = token == null ? \"\" : token.trim().toUpperCase();\n    return \"*\".equals(t) || \"?\".equals(t) || \"L\".equals(t)\n        || t.matches(\"[1-7]\")\n        || t.matches(\"[1-7]L\")\n        || DOW.contains(t);\n}","tryCatchPattern":"try {\n    new CronExpression(expr);\n} catch (ParseException e) {\n    if (e.getMessage().startsWith(\"Invalid Day-of-Week value\")) {\n        errors.rejectValue(\"dowField\", \"cron.dow.invalid\",\n            \"Use SUN..SAT or 1..7 (1=SUN). Got: \" + e.getMessage());\n    } else throw e;\n}","preventionTips":["Whitelist day-of-week tokens to SUN..SAT at the input layer.","Prefer numeric dow (1=SUN..7=SAT) in generated expressions.","Offer weekdays from a fixed multi-select in the UI instead of free text."],"tags":["cron","xxl-job","day-of-week","validation","parse-error"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}