alibaba/spring-cloud-alibaba · error · ParseException

Increment > 12 : {}

Error message

Increment > 12 : {}

What it means

Thrown when a step value after '/' exceeds 12 in the MONTH field (guard at CronExpression.java:447-448). Month steps are capped at 12 because a year has twelve months.

Source

Thrown at spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-schedulerx/src/main/java/com/alibaba/cloud/scheduling/schedulerx/util/CronExpression.java:448

				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) {
				lastdayOfMonth = true;
			}
			if (type == DAY_OF_WEEK) {
				addToSet(7, 7, 0, type);
			}
			if (type == DAY_OF_MONTH && s.length() > i) {

View on GitHub (pinned to 115d590110)

Solutions

  1. Use a month step <= 12, e.g. '*/13' -> '*/3' for quarterly.
  2. For a yearly schedule, fix the month (e.g. '0 0 0 1 1 ?') rather than using a step.
  3. Confirm the six fields are correctly ordered.

Example fix

// before
new CronExpression("0 0 0 ? */13 *");
// after
new CronExpression("0 0 0 ? */3 *"); // every 3 months (quarterly)
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

When it happens

Trigger: `new CronExpression("0 0 0 ? */13 *")` (month step 13) or any step > 12 in the month position.

Common situations: Developer wants a quarterly or yearly cadence and overstates the step, or a field misalignment places a large value in the month field.

Related errors


AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14). Data as JSON: /api/errors/332766b64617a900. Report an issue: GitHub.