hashicorp/nomad · error

cron.end must not contain %q

Error message

cron.end must not contain %q

What it means

Returned by TaskSchedule.Validate when cron.end contains '/' or ',' (steps or lists). Schedule start/end expressions restrict those characters because the scheduler completes them into full cron expressions.

Source

Thrown at nomad/structs/task_sched.go:86

	}

	const (
		startFields     = 6
		endFields       = 2
		restrictedChars = "/,"
	)

	if strings.Count(t.Cron.Start, " ") != (startFields - 1) {
		return fmt.Errorf("cron.start must contain %d fields", startFields)
	}
	if strings.Count(t.Cron.End, " ") != (endFields - 1) {
		return fmt.Errorf("cron.end must contain %d fields", endFields)
	}
	if strings.ContainsAny(t.Cron.Start, restrictedChars) {
		return fmt.Errorf("cron.start must not contain %q", restrictedChars)
	}
	if strings.ContainsAny(t.Cron.End, restrictedChars) {
		return fmt.Errorf("cron.end must not contain %q", restrictedChars)
	}

	return nil
}

func (t *TaskSchedule) Next(from time.Time) (start, end time.Duration, err error) {
	return t.Cron.Next(from)
}

type TaskScheduleCron struct {
	// Start is a stripped-down cron syntax, e.g.
	// "0 30 9 * * MON-FRI *"
	// is weekdays @ 09:30:00
	Start string
	// End is the end time in "{minute} {hour}" format, e.g.
	// "30 9"
	// is 09:30 AM
	// The End time *must* come after the Start time.

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use plain values in cron.end without '/' or ','
  2. Split complex end schedules into simpler expressions
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/task_sched.go:86 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/81b52f08a69771cf. Report an issue: GitHub.