alibaba/spring-cloud-alibaba · error · ParseException
Increment > 31 : {}
Error message
Increment > 31 : {} What it means
Thrown when a step value after '/' exceeds 31 in the DAY_OF_MONTH field (guard at CronExpression.java:441-442). Day-of-month steps are capped at 31 because no month has more days.
Source
Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:442
i++;
if (i >= s.length()) {
throw new ParseException("Unexpected end of string.", i);
}
incr = getNumericValue(s, i);
i++;
if (incr > 10) {
i++;
}
if (incr > 59 && (type == SECOND || type == MINUTE)) {
throw new ParseException("Increment > 60 : " + incr, i);
}
else if (incr > 23 && (type == HOUR)) {
throw new ParseException("Increment > 24 : " + incr, i);
}
else if (incr > 31 && (type == DAY_OF_MONTH)) {
throw new ParseException("Increment > 31 : " + incr, i);
}
else if (incr > 7 && (type == DAY_OF_WEEK)) {
throw new ParseException("Increment > 7 : " + incr, i);
}
else if (incr > 12 && (type == MONTH)) {
throw new ParseException("Increment > 12 : " + incr, i);
}
}
else {
incr = 1;
}
addToSet(ALL_SPEC_INT, -1, incr, type);
return i;
}
else if (c == 'L') {
i++;
if (type == DAY_OF_MONTH) {View on GitHub (pinned to 115d590110)
Solutions
- Use a day-of-month step <= 31, e.g. '*/32' -> '*/15'.
- For end-of-month behavior, prefer the 'L' or 'L-N' construct instead of a large step.
- Verify all six fields are present so the step sits in the intended field.
Example fix
// before
new CronExpression("0 0 0 */32 * ?");
// after
new CronExpression("0 0 0 */15 * ?"); // every 15 days Defensive patterns
Strategy: validation
Validate before calling
static boolean stepWithin(String field, int max) {
int slash = field.indexOf('/');
if (slash < 0) return true;
try { return Integer.parseInt(field.substring(slash + 1)) <= max; }
catch (NumberFormatException e) { return false; }
} Try / catch
try {
CronExpression cron = new CronExpression(raw);
} catch (ParseException e) {
throw new IllegalArgumentException("Invalid cron expression: " + raw, e);
} Prevention
- Day-of-month steps cap at 31; use 'L' or 'L-N' for end-of-month needs.
- Range-check injected step values before formatting.
- Verify field ordering so the step targets day-of-month intentionally.
When it happens
Trigger: `new CronExpression("0 0 0 */32 * ?")` (day-of-month step 32) or any step > 31 in the day-of-month position.
Common situations: Developer intends 'last few days' logic or copies a step from another field. A field-count error (missing seconds) is a frequent root cause, placing a large step into day-of-month.
Related errors
- Increment > 60 : {}
- Increment > 24 : {}
- Increment > 7 : {}
- Increment > 12 : {}
- Offset from last day must be <= 30
AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14).
Data as JSON: /api/errors/0eb695178053ef74.
Report an issue: GitHub.