hashicorp/nomad · error

invalid timezone in schedule: %w

Error message

invalid timezone in schedule: %w

What it means

Returned by TaskScheduleCron.Next when time.LoadLocation fails on the schedule's timezone (or the "Local" default). The IANA timezone name is unknown on this system, so times cannot be computed in it.

Source

Thrown at nomad/structs/task_sched.go:128

}

func (t TaskScheduleCron) String() string {
	return fmt.Sprintf("<Start='%s', End='%s', Timezone='%s'>",
		t.Start, t.End, t.Timezone)
}

func (t TaskScheduleCron) GetTimezone() string {
	if t.Timezone == "" {
		return "Local" // https://pkg.go.dev/time#LoadLocation
	}
	return t.Timezone
}

func (t TaskScheduleCron) Next(from time.Time) (time.Duration, time.Duration, error) {
	// where are we?
	location, err := time.LoadLocation(t.GetTimezone())
	if err != nil {
		return 0, 0, fmt.Errorf("invalid timezone in schedule: %w", err)
	}
	from = from.In(location)

	// values should be pre-validated by this point
	start, err := cronexpr.Parse(t.Start)
	if err != nil {
		return 0, 0, fmt.Errorf("invalid start time in schedule: %q; %w", t.Start, err)
	}
	// 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!

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Use a valid IANA timezone name such as "America/New_York"
  2. Ensure tzdata is installed (or import _ "time/tzdata" in the binary) when running in minimal containers
Defensive patterns

Strategy: validation

When it happens

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