nats-io/nats-server · error

end of range (%d) above maximum (%d): %s

Error message

end of range (%d) above maximum (%d): %s

What it means

getRange validates a cron field's range end against the field's maximum (e.g. 59 for minutes/seconds, 23 for hours, 12 for months, 6 for dow). An end above the legal maximum is rejected with the expression included in the message.

Source

Thrown at server/cron.go:225

		if err != nil {
			return 0, err
		}
		// Special handling: "N/step" means "N-max/step".
		if singleDigit {
			end = r.max
		}
		if step > 1 {
			extra = 0
		}
	default:
		return 0, fmt.Errorf("too many slashes: %s", expr)
	}

	if start < r.min {
		return 0, fmt.Errorf("beginning of range (%d) below minimum (%d): %s", start, r.min, expr)
	}
	if end > r.max {
		return 0, fmt.Errorf("end of range (%d) above maximum (%d): %s", end, r.max, expr)
	}
	if start > end {
		return 0, fmt.Errorf("beginning of range (%d) beyond end of range (%d): %s", start, end, expr)
	}
	if step == 0 {
		return 0, fmt.Errorf("step of range should be a positive number: %s", expr)
	}
	return getBits(start, end, step) | extra, nil
}

// parseIntOrName returns the (possibly-named) integer contained in expr.
func parseIntOrName(expr string, names map[string]uint) (uint, error) {
	if names != nil {
		if namedInt, ok := names[strings.ToLower(expr)]; ok {
			return namedInt, nil
		}
	}
	return mustParseInt(expr)

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Clamp the range end to the field max: minutes/seconds 0-59, hours 0-23, dom 1-31, months 1-12, dow 0-6
  2. Replace '7' in day-of-week with '0' (both mean Sunday in classic cron, but 7 exceeds max here)
  3. Use '*' for the whole valid range

Example fix

// before (hour field)
 expr := "9-24"
// after
 expr := "9-23"
Defensive patterns

Strategy: validation

Validate before calling

var fieldMaxs = map[int]uint{0: 59, 1: 59, 2: 23, 3: 31, 4: 12, 5: 6} // sec,min,hour,dom,mon,dow
// check range ends <= fieldMaxs[fieldIdx] before scheduling

Prevention

When it happens

Trigger: A range like minutes "0-60", hours "0-24", months "1-13", or day-of-week "0-7" passed through parseCron -> getField -> getRange.

Common situations: Assuming hours go to 24 (they go 0-23); assuming day-of-week allows 7 like some cron implementations (max is 6 here); copying Linux crontab quirks into the 6-field parser.

Related errors


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/98c0cf6f2d50f0b6. Report an issue: GitHub.