hashicorp/nomad · error

end cannot be sooner than start; end=%q, start=%q

Error message

end cannot be sooner than start; end=%q, start=%q

What it means

Returned by TaskScheduleCron.Next when the parsed end time lands before the corresponding start time, producing an inverted run window. The schedule would never be active, which is treated as a configuration error.

Source

Thrown at nomad/structs/task_sched.go:155

	// get end time for prev to see if we're within the run schedule,
	// and from next to get the next pause time.
	end, err := cronexpr.Parse(t.End + " * * * *") // TODO: if we want to exclude seconds, prefix "* " + t.End here
	if err != nil {
		return 0, 0, fmt.Errorf("invalid end time in schedule: %q; %w", t.End, err)
	}

	startNext := start.Next(from)
	// we'll check the previous start to see if we are currently between it
	// and the previous run's end, i.e. it should be running right now!
	startPrev := start.Next(from.Add(-24 * time.Hour))

	// generate ends from starts, so they always come after
	endNext := end.Next(startNext)
	endPrev := end.Next(startPrev)

	// next end must be on the same day as next start
	if endNext.Day() > startNext.Day() {
		return 0, 0, fmt.Errorf("end cannot be sooner than start; end=%q, start=%q", endNext, startNext)
	}

	// we're in the midst of it right now!
	if startPrev.Before(from) && endPrev.After(from) {
		return 0, endPrev.Sub(from), nil
	}

	return startNext.Sub(from), endNext.Sub(from), nil
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Swap or adjust start/end so end is chronologically after start
  2. Use 24-hour-aware values, e.g. start "0 0 9 * *" and end "17 *" for 9am-5pm
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nomad/structs/task_sched.go:155 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/5f3db5f7e8066695. Report an issue: GitHub.