{"record":{"id":"26ce5a5fc5d59468","repo":"thanos-io/thanos","slug":"failed-to-parse-configuration-file-v","errorCode":null,"errorMessage":"failed to parse configuration file: %v","messagePattern":"failed to parse configuration file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/config.go","lineNumber":402,"sourceCode":"}\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))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\tif err := fd.Close(); err != nil {","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/config.go#L384-L420","documentation":"loadConfig wraps any error from ParseConfig with the message 'failed to parse configuration file', preserving the underlying parse error. The receiver's configuration file must be valid THanos-style hashring configuration; if its content cannot be parsed into a []HashringConfig, this error is returned. The wrapped sentinel errParseConfigurationFile allows programmatic detection.","triggerScenarios":"loadConfig (called by ValidateConfig and refresh) reads the config file successfully but ParseConfig fails — i.e. the file content is malformed YAML/JSON or does not unmarshal into the expected hashring schema.","commonSituations":"Hand-edited hashring configuration with wrong indentation, missing 'endpoints' field, wrong types (string where a list is expected), a file that is valid YAML but not valid hashring config, or an empty/garbage file passed via --receive.config-file.","solutions":["Validate the config before deployment with the Thanos `thanos tools bucket verify`-style sidecar tooling or by calling ValidateConfig on startup","Fix the YAML/JSON syntax and schema in the configuration file (check field names: tops, hashes, endpoints)","Check the wrapped error (%v at the end of the message) for the exact line/field that failed to unmarshal","Confirm the file at the --receive.config-file path contains hashring config, not another format"],"exampleFix":"// before (broken hashring YAML)\nhashring:tenant-a:\n  - endpoints: ['thanos-receive-0:10901']\n// after\ntenants:\n  - endpoints: ['thanos-receive-0:10901']","handlingStrategy":"validation","validationCode":"if err := rcv.ValidateConfig(cfgBytes); err != nil { return fmt.Errorf(\"invalid receive config: %w\", err) }","typeGuard":null,"tryCatchPattern":"if _, _, err := receive.ValidateConfig(cfg); err != nil {\n    if errors.Is(err, receive.ErrParseConfigurationFile) { /* handle schema error */ }\n    return err\n}","preventionTips":["Run the config through ValidateConfig in CI or at startup before committing to it","Keep hashring files under schema-aware validation (JSON schema / lint in config management)","Check the wrapped %v message to find the exact offending field or line","Version-control hashring files so bad edits are reviewable"],"tags":["config","parsing","thanos-receive"],"backgroundTag":"schema-validation-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"}