hashicorp/nomad · error

wait config is nil or empty

Error message

wait config is nil or empty

What it means

WaitConfig.Validate returns this error when the WaitConfig is nil or empty (IsEmpty true), meaning it can never be used to derive a wait interval. It exists so callers never assign a useless WaitConfig to a watched value's wait settings.

Source

Thrown at client/config/config.go:700

// Equal returns the result of reflect.DeepEqual
func (wc *WaitConfig) Equal(other *WaitConfig) bool {
	return reflect.DeepEqual(wc, other)
}

// IsEmpty returns true if the receiver only contains an instance with no fields set.
func (wc *WaitConfig) IsEmpty() bool {
	if wc == nil {
		return true
	}
	return wc.Equal(&WaitConfig{})
}

// Validate returns an error  if the receiver is nil or empty or if Min is greater
// than Max the user specified Max.
func (wc *WaitConfig) Validate() error {
	// If the config is nil or empty return false so that it is never assigned.
	if wc == nil || wc.IsEmpty() {
		return errors.New("wait config is nil or empty")
	}

	// If min is nil, return
	if wc.Min == nil {
		return nil
	}

	// If min isn't nil, make sure Max is less than Min.
	if wc.Max != nil {
		if *wc.Min > *wc.Max {
			return fmt.Errorf("wait config min %d is greater than max %d", *wc.Min, *wc.Max)
		}
	}

	// Otherwise, return nil. Consul Template will set a Max based off of Min.
	return nil
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Populate Min and Max in the wait config (e.g. min = "5s", max = "10s")
  2. Remove the empty wait block entirely so defaults apply instead
  3. Guard before assigning: only call/act on Validate for non-nil, non-empty configs
  4. Check config decoding actually maps the wait keys (typos like wait_min are ignored)

Example fix

// before
wait = {}
// after (HCL)
wait = {
  min = "5s"
  max = "10s"
}
Defensive patterns

Strategy: validation

Validate before calling

// before assigning or validating, ensure the WaitConfig is usable
if wc == nil || wc.IsEmpty() {
    // use defaults instead
    wc = config.DefaultWaitConfig()
} else if err := wc.Validate(); err != nil {
    return err
}

Type guard

func validWaitConfig(wc *config.WaitConfig) bool {
    return wc != nil && !wc.IsEmpty()
}

Try / catch

if err := wc.Validate(); err != nil {
    if err.Error() == "wait config is nil or empty" {
        wc = config.DefaultWaitConfig() // fall back to defaults
    } else {
        return err // min > max etc.
    }
}

Prevention

When it happens

Trigger: Calling Validate() on a nil *WaitConfig, or on one where both Min and Max (all durations) are unset — typically after decoding config where the wait block was present but empty, or a programmatic WaitConfig built with no fields set.

Common situations: Empty `wait {}` block in job/client config; template config with wait = 0 or unset keys; code constructing &config.WaitConfig{} without setting Min/Max before validating.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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