{"record":{"id":"d1099dfea3143b29","repo":"thanos-io/thanos","slug":"unable-to-load-config-file","errorCode":null,"errorMessage":"unable to load config file","messagePattern":"unable to load config file","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/endpointset.go","lineNumber":249,"sourceCode":"\tstaticEndpoints []string,\n\tstaticEndpointGroups []string,\n\tstaticStrictEndpoints []string,\n\tstaticStrictEndpointGroups []string,\n) (*endpointConfigProvider, error) {\n\tres := &endpointConfigProvider{\n\t\tendpoints:            staticEndpoints,\n\t\tendpointGroups:       staticEndpointGroups,\n\t\tstrictEndpoints:      staticStrictEndpoints,\n\t\tstrictEndpointGroups: staticStrictEndpointGroups,\n\t}\n\n\tif configFile == nil {\n\t\tconfigFile = extkingpin.NewNopConfig()\n\t}\n\n\tcfg, err := res.parse(configFile)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to load config file\")\n\t}\n\tres.addStaticEndpoints(&cfg)\n\tif err := validateEndpointConfig(&cfg); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to validate endpoints\")\n\t}\n\tres.cfg = cfg\n\n\t// only static endpoints\n\tif len(configFile.Path()) == 0 {\n\t\treturn res, nil\n\t}\n\n\tif err := extkingpin.PathContentReloader(context.Background(), configFile, logger, func() {\n\t\tres.mu.Lock()\n\t\tdefer res.mu.Unlock()\n\n\t\tlevel.Info(logger).Log(\"msg\", \"reloading endpoint config\")\n\t\tcfg, err := res.parse(configFile)","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/endpointset.go#L231-L267","documentation":"Wrapper raised in newEndpointConfigProvider when the initial parse() of the endpoint config file fails. It combines all content-load failures (I/O and unmarshal) under a single message 'unable to load config file' and prevents StoreAPI endpoint set construction. The underlying parse error (with file path) is chained.","triggerScenarios":"newEndpointConfigProvider is called with a configFile whose Content() fails (missing/unreadable file) or whose YAML cannot be unmarshaled into EndpointConfig; setupEndpointSet then fails at startup.","commonSituations":"Thanos Query started with --endpoint-config pointing to a nonexistent file; k8s projected volume not mounted yet at process start; malformed YAML in the config file.","solutions":["Ensure the endpoint config file exists and is readable at the path given to --endpoint-config before starting Thanos.","Fix YAML syntax/types in the file (see the chained parse error for the exact path).","If you don't need file-based endpoints, use static --endpoint flags instead so a NopConfig is used.","For k8s, add an init container or readiness gate ensuring the ConfigMap/Secret is mounted before Thanos starts."],"exampleFix":"// before: starting query with missing file\n// thanos query --endpoint-config=/etc/thanos/endpoints.yaml\n// after: guard in startup script\n// test -r /etc/thanos/endpoints.yaml || { echo 'endpoint config missing'; exit 1; }\n// thanos query --endpoint-config=/etc/thanos/endpoints.yaml","handlingStrategy":"validation","validationCode":"func ensureEndpointConfig(path string) error { if path == \"\" { return nil }; b, err := os.ReadFile(path); if err != nil { return err }; var c EndpointConfig; return yaml.Unmarshal(b, &c) }","typeGuard":"func configPresent(p string) bool { if p == \"\" { return true }; _, err := os.Stat(p); return err == nil }","tryCatchPattern":"res, err := newEndpointConfigProvider(logger, reg, configFile, ...)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to load config file\") { log.Fatalf(\"fix --endpoint-config: %v\", err) }\n    return err\n}","preventionTips":["Use static --endpoint flags if you don't need dynamic reload.","Gate container startup on config mount existence (initContainer or entrypoint check).","Validate file YAML in CI pipelines that render the config.","Avoid NFS paths for watched config files."],"tags":["config","startup","file-io","thanos"],"backgroundTag":"config-file-not-found","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"}