{"record":{"id":"c93ccae4306e8bf8","repo":"slackhq/nebula","slug":"empty-configuration","errorCode":null,"errorMessage":"Empty configuration","messagePattern":"Empty configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/config.go","lineNumber":66,"sourceCode":"\t}\n\n\tif len(c.files) == 0 {\n\t\treturn fmt.Errorf(\"no config files found at %s\", path)\n\t}\n\n\tsort.Strings(c.files)\n\n\terr = c.parse()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc (c *C) LoadString(raw string) error {\n\tif raw == \"\" {\n\t\treturn errors.New(\"Empty configuration\")\n\t}\n\treturn c.parseRaw([]byte(raw))\n}\n\n// RegisterReloadCallback stores a function to be called when a config reload is triggered. The functions registered\n// here should decide if they need to make a change to the current process before making the change. HasChanged can be\n// used to help decide if a change is necessary.\n// These functions should return quickly or spawn their own go routine if they will take a while\nfunc (c *C) RegisterReloadCallback(f func(*C)) {\n\tc.callbacks = append(c.callbacks, f)\n}\n\n// InitialLoad returns true if this is the first load of the config, and ReloadConfig has not been called yet.\nfunc (c *C) InitialLoad() bool {\n\treturn c.oldSettings == nil\n}\n\n// HasChanged checks if the underlying structure of the provided key has changed after a config reload. The value of","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/config/config.go#L48-L84","documentation":"C.LoadString in config/config.go refuses to load an empty configuration string: if raw == \"\" it returns errors.New(\"Empty configuration\") without calling parseRaw. It guards against accidentally reloading/starting with no config content at all.","triggerScenarios":"Calling LoadString(\"\") directly, or indirectly when a file read yields empty content and callers pipe it into LoadString via ReloadConfigString, run, or newSimpleService.","commonSituations":"Config file exists but is zero bytes (truncated write, failed mount, empty k8s Secret/ConfigMap); template rendering produced nothing; reading a file before it was written.","solutions":["Check the config source is non-empty before loading (stat/read validation).","Fix the upstream source: restore the file, fix the Secret/ConfigMap, or correct the template that rendered empty output.","In code, return a clearer wrapper error or skip reload when the raw string is empty.","If an empty config is legitimate, use parseRaw/Load with a valid minimal document like '{}' instead of an empty string."],"exampleFix":"// before\nraw, _ := os.ReadFile(cfgPath)\nerr := c.LoadString(string(raw))\n\n// after\nraw, err := os.ReadFile(cfgPath)\nif err != nil { return err }\nif len(bytes.TrimSpace(raw)) == 0 { return fmt.Errorf(\"config file %s is empty\", cfgPath) }\nreturn c.LoadString(string(raw))","handlingStrategy":"validation","validationCode":"raw, err := os.ReadFile(cfgPath)\nif err != nil { return err }\nif len(bytes.TrimSpace(raw)) == 0 {\n    return fmt.Errorf(\"config %s is empty; refusing to load\", cfgPath)\n}\nerr = c.LoadString(string(raw))","typeGuard":"func isNonEmptyConfig(raw string) bool {\n    return len(strings.TrimSpace(raw)) > 0\n}","tryCatchPattern":"if err := c.LoadString(raw); err != nil {\n    if err.Error() == \"Empty configuration\" {\n        return fmt.Errorf(\"config source empty: check %s content/mount\", cfgPath)\n    }\n    return err\n}","preventionTips":["Check file size / Secret content before load in deployment manifests.","Fail readiness probes until config is non-empty and parses.","Avoid truncated atomic writes: write to temp file then rename.","Log the config source path with the error to speed diagnosis."],"tags":["config","validation","go"],"backgroundTag":"empty-configuration","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}