{"record":{"id":"eb809ded283fb3de","repo":"hashicorp/nomad","slug":"wait-config-is-nil-or-empty","errorCode":null,"errorMessage":"wait config is nil or empty","messagePattern":"wait config is nil or empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/config/config.go","lineNumber":700,"sourceCode":"// Equal returns the result of reflect.DeepEqual\nfunc (wc *WaitConfig) Equal(other *WaitConfig) bool {\n\treturn reflect.DeepEqual(wc, other)\n}\n\n// IsEmpty returns true if the receiver only contains an instance with no fields set.\nfunc (wc *WaitConfig) IsEmpty() bool {\n\tif wc == nil {\n\t\treturn true\n\t}\n\treturn wc.Equal(&WaitConfig{})\n}\n\n// Validate returns an error  if the receiver is nil or empty or if Min is greater\n// than Max the user specified Max.\nfunc (wc *WaitConfig) Validate() error {\n\t// If the config is nil or empty return false so that it is never assigned.\n\tif wc == nil || wc.IsEmpty() {\n\t\treturn errors.New(\"wait config is nil or empty\")\n\t}\n\n\t// If min is nil, return\n\tif wc.Min == nil {\n\t\treturn nil\n\t}\n\n\t// If min isn't nil, make sure Max is less than Min.\n\tif wc.Max != nil {\n\t\tif *wc.Min > *wc.Max {\n\t\t\treturn fmt.Errorf(\"wait config min %d is greater than max %d\", *wc.Min, *wc.Max)\n\t\t}\n\t}\n\n\t// Otherwise, return nil. Consul Template will set a Max based off of Min.\n\treturn nil\n}\n","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/config/config.go#L682-L718","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Populate Min and Max in the wait config (e.g. min = \"5s\", max = \"10s\")","Remove the empty wait block entirely so defaults apply instead","Guard before assigning: only call/act on Validate for non-nil, non-empty configs","Check config decoding actually maps the wait keys (typos like wait_min are ignored)"],"exampleFix":"// before\nwait = {}\n// after (HCL)\nwait = {\n  min = \"5s\"\n  max = \"10s\"\n}","handlingStrategy":"validation","validationCode":"// before assigning or validating, ensure the WaitConfig is usable\nif wc == nil || wc.IsEmpty() {\n    // use defaults instead\n    wc = config.DefaultWaitConfig()\n} else if err := wc.Validate(); err != nil {\n    return err\n}","typeGuard":"func validWaitConfig(wc *config.WaitConfig) bool {\n    return wc != nil && !wc.IsEmpty()\n}","tryCatchPattern":"if err := wc.Validate(); err != nil {\n    if err.Error() == \"wait config is nil or empty\" {\n        wc = config.DefaultWaitConfig() // fall back to defaults\n    } else {\n        return err // min > max etc.\n    }\n}","preventionTips":["Always specify both min and max in wait blocks","Use config schema/defaults rather than hand-rolling empty structs","Check for key typos in HCL so wait fields actually decode","Log a warning (rather than failing) when an empty wait config is dropped"],"tags":["nomad","config","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}