{"record":{"id":"90d0d43ad5d04867","repo":"thanos-io/thanos","slug":"failed-to-read-configuration-file","errorCode":null,"errorMessage":"failed to read configuration file","messagePattern":"failed to read configuration file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/config.go","lineNumber":397,"sourceCode":"\t\t\tupdates <- cfg\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\t}\n\t}\n}\n\n// ParseConfig parses the raw configuration content and returns a HashringConfig.\nfunc ParseConfig(content []byte) ([]HashringConfig, error) {\n\tvar config []HashringConfig\n\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))","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/config.go#L379-L415","documentation":"loadConfig wraps any failure from readFile(logger, path) — reading the raw hashring configuration file — with 'failed to read configuration file'. This fires before parsing, so it indicates an I/O-level problem (missing file, permission denied, read error) rather than a content problem.","triggerScenarios":"loadConfig -> readFile fails: the --hashrings-file path does not exist, permissions deny reading, the path is a directory, or an I/O error occurs while reading.","commonSituations":"ConfigMap/secret not mounted at the expected path; wrong flag value; file deleted while the config watcher's periodic refresh runs; non-root process lacking read permission on a root-owned mount.","solutions":["Verify the file exists at the exact configured path and is readable by the process (ls -l, cat as the run user)","Fix the --hashrings-file flag or mount configuration so the file is present","Restore the file if it was deleted mid-run; the periodic refresh will pick it up on the next interval","Check volume mount permissions/ownership for non-root containers"],"exampleFix":"// before\nhashringsFile: \"/etc/thanos/wrong-name.json\"\n// after\nhashringsFile: \"/etc/thanos/hashrings.json\"  # mounted, mode 0444","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil { return fmt.Errorf(\"config file not accessible: %w\", err) }\nif !info.Mode().IsRegular() { return errors.New(\"config path is not a regular file\") }\nf, err := os.Open(path)\nif err != nil { return fmt.Errorf(\"permission denied reading config: %w\", err) }\nf.Close()","typeGuard":null,"tryCatchPattern":"_, _, err := receive.ValidateConfig(logger, path)\nif err != nil && strings.Contains(err.Error(), \"failed to read configuration file\") {\n\t// check path/mount/permissions before restarting\n}","preventionTips":["Verify the mounted config path in your deployment manifests","Give the process user explicit read permission on the config file","Monitor that the config file exists throughout the pod lifetime, not just at startup"],"tags":["file-io","config","hashring"],"backgroundTag":"file-read-failed","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"}