{"record":{"id":"4fe908a273c6ebbe","repo":"alibaba/spring-cloud-alibaba","slug":"invalid-month-value","errorCode":null,"errorMessage":"Invalid Month value: '{}'","messagePattern":"Invalid Month 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":338,"sourceCode":"\t}\n\n\tprotected int storeExpressionVals(final int pos, final String s, final int type)\n\t\t\tthrows ParseException {\n\n\t\tint incr = 0;\n\t\tint i = skipWhiteSpace(pos, s);\n\t\tif (i >= s.length()) {\n\t\t\treturn i;\n\t\t}\n\t\tchar c = s.charAt(i);\n\t\tif ((c >= 'A') && (c <= 'Z') && (!s.equals(\"L\")) && (!s.equals(\"LW\")) && (!s.matches(\"^L-[0-9]*[W]?\"))) {\n\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;","sourceCodeStart":320,"sourceCodeEnd":356,"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#L320-L356","documentation":"Thrown in storeExpressionVals while parsing the MONTH field: when a token starts with a letter A-Z (so it is treated as a named month), getMonthNumber(sub) returns -1 because the three-letter abbreviation is not recognized (JAN..DEC). The parser then throws ParseException 'Invalid Month value: \\'<sub>\\''.","triggerScenarios":"A month field with an unrecognised 3-letter token, e.g. '0 0 0 * ABC ?' or a typo like '0 0 0 * JUN ?' (note: only JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC are valid — 'ABC' is not). The check at CronExpression.java:343-345 fires when sval <= 0.","commonSituations":"Typo in a month abbreviation; using a full month name 'JANUARY' instead of 'JAN'; locale/uppercase issues where the value is not uppercased (the parser uppercases the whole expression, so this is usually a genuine typo).","solutions":["Use a valid three-letter English month abbreviation (JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC) or a numeric value 1-12.","Double-check the spelling; the parser only accepts the exact abbreviations in monthMap.","Validate at config load."],"exampleFix":"# before (typo)\n0 0 0 * JNA ?\n\n# after\n0 0 0 * JAN ?","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> MONTHS = java.util.Set.of(\n    \"JAN\",\"FEB\",\"MAR\",\"APR\",\"MAY\",\"JUN\",\"JUL\",\"AUG\",\"SEP\",\"OCT\",\"NOV\",\"DEC\");\nstatic boolean validMonthToken(String t) {\n    return MONTHS.contains(t) || t.matches(\"\\\\d+(/\\\\d+)?(-\\\\d+)?\");\n}","tryCatchPattern":"try {\n    new CronExpression(cron);\n} catch (ParseException e) {\n    // \"Invalid Month value: 'JNA'\"\n    log.error(\"Bad month in cron '{}': {}\", cron, e.getMessage());\n}","preventionTips":["Prefer numeric months (1-12) to avoid spelling mistakes.","Trial-parse crons during validation to surface bad month tokens early."],"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"}