{"record":{"id":"96b273909e4e9e07","repo":"thanos-io/thanos","slug":"failed-to-load-configuration-file-path-s","errorCode":null,"errorMessage":"failed to load configuration file, path: %s","messagePattern":"failed to load configuration file, path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/config.go","lineNumber":407,"sourceCode":"\terr := json.Unmarshal(content, &config)\n\treturn config, err\n}\n\n// loadConfig loads raw configuration content and returns a configuration.\nfunc loadConfig(logger log.Logger, path string) ([]HashringConfig, float64, error) {\n\tcfgContent, err := readFile(logger, path)\n\tif err != nil {\n\t\treturn nil, 0, errors.Wrap(err, \"failed to read configuration file\")\n\t}\n\n\tconfig, err := ParseConfig(cfgContent)\n\tif err != nil {\n\t\treturn nil, 0, errors.Wrapf(errParseConfigurationFile, \"failed to parse configuration file: %v\", err)\n\t}\n\n\t// If hashring is empty, return an error.\n\tif len(config) == 0 {\n\t\treturn nil, 0, errors.Wrapf(errEmptyConfigurationFile, \"failed to load configuration file, path: %s\", path)\n\t}\n\n\treturn config, hashAsMetricValue(cfgContent), nil\n}\n\n// readFile reads the configuration file and returns content of configuration file.\nfunc readFile(logger log.Logger, path string) ([]byte, error) {\n\tfd, err := os.Open(filepath.Clean(path))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\tif err := fd.Close(); err != nil {\n\t\t\tlevel.Error(logger).Log(\"msg\", \"failed to close file\", \"err\", err, \"path\", path)\n\t\t}\n\t}()\n\n\treturn io.ReadAll(fd)","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/config.go#L389-L425","documentation":"loadConfig wraps the sentinel errEmptyConfigurationFile when the parsed configuration yields an empty hashring list (len(config) == 0). This means the file was readable and parseable but contained no hashring entries, so the receiver would have nowhere to route/replicate writes.","triggerScenarios":"loadConfig successfully reads and parses the file, but ParseConfig returns a zero-length []HashringConfig — e.g. the file contains an empty list, only comments, or a YAML document that unmarshals to no hashrings.","commonSituations":"An operator points --receive.config-file at a placeholder/empty file, the config management tool rendered the file to an empty list, or the file was truncated after a failed templating deploy.","solutions":["Populate the hashring configuration with at least one entry containing valid endpoints","If the receiver is meant to run with hashring disabled, use the appropriate no-hashing flag instead of an empty hashring file","Check the rendered file on disk (`cat`) to confirm your config management actually wrote the entries","Verify the parse step is not silently discarding entries due to wrong top-level key"],"exampleFix":"// before: empty config file\n# (no entries)\n// after\n- endpoints:\n    - thanos-receive-0.thanos-receive:10901\n    - thanos-receive-1.thanos-receive:10901","handlingStrategy":"validation","validationCode":"cfg, _, err := receive.ValidateConfig(cfgBytes)\nif err != nil { return err }\nif len(cfg) == 0 { return errors.New(\"hashring config must contain at least one entry\") }","typeGuard":null,"tryCatchPattern":"if err != nil && errors.Is(err, receive.ErrEmptyConfigurationFile) {\n    log.Error(\"hashring config is empty; refusing to start\")\n}","preventionTips":["Assert rendered config files are non-empty in your deploy pipeline before rollout","Use readiness gates so a receiver never starts with an empty hashring file","If running without hashing, use the dedicated no-hashing mode rather than an empty file","Add a smoke check that parses the file after templating"],"tags":["config","empty","hashring"],"backgroundTag":"empty-result-set","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}