{"record":{"id":"f7f838c1acdcddb9","repo":"hashicorp/nomad","slug":"wait-config-is-empty","errorCode":null,"errorMessage":"wait config is empty","messagePattern":"wait config is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/config/config.go","lineNumber":752,"sourceCode":"\tif b.MinHCL != \"\" {\n\t\tresult.MinHCL = b.MinHCL\n\t}\n\n\tif b.Max != nil {\n\t\tresult.Max = &*b.Max\n\t}\n\n\tif b.MaxHCL != \"\" {\n\t\tresult.MaxHCL = b.MaxHCL\n\t}\n\n\treturn &result\n}\n\n// ToConsulTemplate converts a client WaitConfig instance to a consul-template WaitConfig\nfunc (wc *WaitConfig) ToConsulTemplate() (*config.WaitConfig, error) {\n\tif wc.IsEmpty() {\n\t\treturn nil, errors.New(\"wait config is empty\")\n\t}\n\n\tif err := wc.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tenabled := wc.Min == nil || *wc.Min != 0 || wc.Max == nil || *wc.Max != 0\n\tresult := &config.WaitConfig{Enabled: new(enabled)}\n\n\tif wc.Min != nil {\n\t\tresult.Min = wc.Min\n\t}\n\n\tif wc.Max != nil {\n\t\tresult.Max = wc.Max\n\t}\n\n\treturn result, nil","sourceCodeStart":734,"sourceCodeEnd":770,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/config/config.go#L734-L770","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set Min (and ideally Max) on the WaitConfig before converting","Skip conversion when IsEmpty() is true and use consul-template defaults instead","Fix the source config so the wait block has real duration values","Verify field mapping during config decode (misspelled keys yield an empty struct)"],"exampleFix":"// before\nwc := &config.WaitConfig{}\nctWc, err := wc.ToConsulTemplate() // err: wait config is empty\n// after\nwc := &config.WaitConfig{Min: &minDur, Max: &maxDur} // minDur=5s, maxDur=10s\nctWc, err := wc.ToConsulTemplate()","handlingStrategy":"validation","validationCode":"// guard before converting\nif wc.IsEmpty() {\n    return nil, nil // or use consul-template defaults\n}\nctWc, err := wc.ToConsulTemplate()","typeGuard":"func convertibleWaitConfig(wc *config.WaitConfig) bool {\n    return wc != nil && !wc.IsEmpty()\n}","tryCatchPattern":"ctWc, err := wc.ToConsulTemplate()\nif err != nil {\n    if err.Error() == \"wait config is empty\" {\n        ctWc = nil // fall back to consul-template defaults\n    } else {\n        return err // propagate Validate() errors (min > max)\n    }\n}","preventionTips":["Check IsEmpty() before calling ToConsulTemplate","Populate Min and Max when building WaitConfig programmatically","Ensure upstream config decoding fills the wait struct (no key typos)","Centralize WaitConfig construction in one helper that enforces non-empty values"],"tags":["nomad","config","consul-template","conversion"],"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"}