{"record":{"id":"5e3d4f139e61e627","repo":"alibaba/spring-cloud-alibaba","slug":"minute-and-second-values-must-be-between-0-and-59","errorCode":null,"errorMessage":"Minute and Second values must be between 0 and 59","messagePattern":"Minute and Second values must be between 0 and 59","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":768,"sourceCode":"\t\treturn i;\n\t}\n\n\tprotected int findNextWhiteSpace(int i, final String s) {\n\t\tfor (; i < s.length() && (s.charAt(i) != ' ' || s.charAt(i) != '\\t'); i++) {\n\t\t\t// empty\n\t\t}\n\n\t\treturn i;\n\t}\n\n\tprotected void addToSet(final int val, final int end, int incr, final int type)\n\t\t\tthrows ParseException {\n\n\t\tfinal TreeSet<Integer> set = getSet(type);\n\n\t\tif (type == SECOND || type == MINUTE) {\n\t\t\tif ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {\n\t\t\t\tthrow new ParseException(\n\t\t\t\t\t\t\"Minute and Second values must be between 0 and 59\",\n\t\t\t\t\t\t-1);\n\t\t\t}\n\t\t}\n\t\telse if (type == HOUR) {\n\t\t\tif ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {\n\t\t\t\tthrow new ParseException(\n\t\t\t\t\t\t\"Hour values must be between 0 and 23\", -1);\n\t\t\t}\n\t\t}\n\t\telse if (type == DAY_OF_MONTH) {\n\t\t\tif ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)\n\t\t\t\t\t&& (val != NO_SPEC_INT)) {\n\t\t\t\tthrow new ParseException(\n\t\t\t\t\t\t\"Day of month values must be between 1 and 31\", -1);\n\t\t\t}\n\t\t}\n\t\telse if (type == MONTH) {","sourceCodeStart":750,"sourceCodeEnd":786,"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#L750-L786","documentation":"Thrown in addToSet when a SECOND or MINUTE value (or range end) is outside 0-59, unless it is the ALL_SPEC wildcard sentinel (guard at CronExpression.java:771-775). This catches out-of-range literal values that slipped past the earlier step checks.","triggerScenarios":"`new CronExpression(\"60 * * * * ?\")` (seconds=60), or `0 60 * * * ?` (minutes=60), or a range like `0 0-60 * * * ?` (end=60).","commonSituations":"Using 60 for 'top of the minute' (invalid; seconds are 0-59), a 1-based minute assumption, or a field-shift placing a larger value into seconds/minutes.","solutions":["Keep seconds and minutes in 0-59, e.g. '60' -> '0' or '59'.","For 'every minute at second 0' use '0 * * * * ?', not '60'.","Recount the six fields so values land in the correct position."],"exampleFix":"// before\nnew CronExpression(\"60 * * * * ?\");\n// after\nnew CronExpression(\"0 * * * * ?\"); // at second 0 of every minute","handlingStrategy":"validation","validationCode":"// Seconds(0) and minutes(1) literals must be 0..59 (ignoring '*' and '?').\nstatic boolean timeFieldsInRange(String[] fields) {\n    if (fields.length < 3) return false;\n    return inRange(fields[0], 0, 59) && inRange(fields[1], 0, 59);\n}\nprivate static boolean inRange(String f, int lo, int hi) {\n    if (f.equals(\"*\") || f.equals(\"?\")) return true;\n    for (String part : f.split(\"[-,/LW#]\")) {\n        if (part.isEmpty()) continue;\n        try { int v = Integer.parseInt(part); if (v < lo || v > hi) return false; }\n        catch (NumberFormatException e) { /* names handled elsewhere */ }\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n    CronExpression cron = new CronExpression(raw);\n} catch (ParseException e) {\n    throw new IllegalArgumentException(\"Invalid cron expression: \" + raw, e);\n}","preventionTips":["Seconds and minutes are 0-59; never use 60.","Range-check time values at the configuration boundary.","Recount fields to avoid shifting larger values into time fields."],"tags":["cron","schedulerx","spring-cloud-alibaba","configuration","parsing","validation","range-check"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}