hashicorp/nomad · error

wait config is empty

Error message

wait config is empty

What it means

WaitConfig.ToConsulTemplate returns this error when the client WaitConfig is empty (IsEmpty true), since an empty config cannot be converted into a consul-template WaitConfig. Unlike Validate, it does not accept nil handling separately — any empty config is rejected outright.

Source

Thrown at client/config/config.go:752

	if b.MinHCL != "" {
		result.MinHCL = b.MinHCL
	}

	if b.Max != nil {
		result.Max = &*b.Max
	}

	if b.MaxHCL != "" {
		result.MaxHCL = b.MaxHCL
	}

	return &result
}

// ToConsulTemplate converts a client WaitConfig instance to a consul-template WaitConfig
func (wc *WaitConfig) ToConsulTemplate() (*config.WaitConfig, error) {
	if wc.IsEmpty() {
		return nil, errors.New("wait config is empty")
	}

	if err := wc.Validate(); err != nil {
		return nil, err
	}

	enabled := wc.Min == nil || *wc.Min != 0 || wc.Max == nil || *wc.Max != 0
	result := &config.WaitConfig{Enabled: new(enabled)}

	if wc.Min != nil {
		result.Min = wc.Min
	}

	if wc.Max != nil {
		result.Max = wc.Max
	}

	return result, nil

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set Min (and ideally Max) on the WaitConfig before converting
  2. Skip conversion when IsEmpty() is true and use consul-template defaults instead
  3. Fix the source config so the wait block has real duration values
  4. Verify field mapping during config decode (misspelled keys yield an empty struct)

Example fix

// before
wc := &config.WaitConfig{}
ctWc, err := wc.ToConsulTemplate() // err: wait config is empty
// after
wc := &config.WaitConfig{Min: &minDur, Max: &maxDur} // minDur=5s, maxDur=10s
ctWc, err := wc.ToConsulTemplate()
Defensive patterns

Strategy: validation

Validate before calling

// guard before converting
if wc.IsEmpty() {
    return nil, nil // or use consul-template defaults
}
ctWc, err := wc.ToConsulTemplate()

Type guard

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

Try / catch

ctWc, err := wc.ToConsulTemplate()
if err != nil {
    if err.Error() == "wait config is empty" {
        ctWc = nil // fall back to consul-template defaults
    } else {
        return err // propagate Validate() errors (min > max)
    }
}

Prevention

When it happens

Trigger: Calling ToConsulTemplate() on a WaitConfig with no Min/Max durations set — e.g. during template/watched-value conversion when the source config block was empty or all fields were zero.

Common situations: Empty wait stanza in template/client configuration being handed to consul-template machinery; code paths converting user config where an optional wait block was left blank; programmatic construction of WaitConfig{} without values.

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/f7f838c1acdcddb9. Report an issue: GitHub.