{"record":{"id":"2f45c549c82e3ba4","repo":"thanos-io/thanos","slug":"unable-to-load-config-initially","errorCode":null,"errorMessage":"unable to load config initially","messagePattern":"unable to load config initially","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/endpointset.go","lineNumber":319,"sourceCode":"\tqueryTimeout time.Duration,\n\tdialOpts []grpc.DialOption,\n\tglobalTLSConfig *tlsConfig,\n\tglobalTLSOpt grpc.DialOption,\n\tglobalCompression string,\n\tinjectTestAddresses []string,\n\tqueryConnMetricLabels ...string,\n) (*query.EndpointSet, error) {\n\tconfigProvider, err := newEndpointConfigProvider(\n\t\tlogger,\n\t\tconfigFile,\n\t\tconfigReloadInterval,\n\t\tlegacyEndpoints,\n\t\tlegacyEndpointGroups,\n\t\tlegacyStrictEndpoints,\n\t\tlegacyStrictEndpointGroups,\n\t)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to load config initially\")\n\t}\n\t// Register resolver for the \"thanos:///\" scheme for endpoint-groups\n\tdns.RegisterGRPCResolver(\n\t\tlogger,\n\t\tdns.NewProvider(\n\t\t\tlogger,\n\t\t\textprom.WrapRegistererWithPrefix(fmt.Sprintf(\"thanos_%s_endpoint_groups_\", comp), reg),\n\t\t\tdns.ResolverType(dnsSDResolver),\n\t\t),\n\t\tdnsSDInterval,\n\t\tinjectTestAddresses,\n\t)\n\tdnsEndpointProvider := dns.NewProvider(\n\t\tlogger,\n\t\textprom.WrapRegistererWithPrefix(fmt.Sprintf(\"thanos_%s_endpoints_\", comp), reg),\n\t\tdns.ResolverType(dnsSDResolver),\n\t)\n\tduplicatedEndpoints := promauto.With(reg).NewCounter(prometheus.CounterOpts{","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/endpointset.go#L301-L337","documentation":"Wrapper in setupEndpointSet for failures from newEndpointConfigProvider during the initial endpoint config load. Any of the inner failures — file read, YAML unmarshal, validation, or reloader creation — surfaces here, preventing the Query/Rule endpoint set from starting. The specific cause is always chained below this message.","triggerScenarios":"setupEndpointSet is invoked by runQuery/runRule (or callers) and calls newEndpointConfigProvider(legacy flags + configFile); any parse/validate/reloader error propagates wrapped as 'unable to load config initially'.","commonSituations":"First boot of thanos query with a bad --endpoint-config file (missing, malformed, or invalid entries); typo in legacy --endpoint flags combined with file config producing validation failures; permissions on the mounted config.","solutions":["Read the full chained error to identify whether it was load, unmarshal, validate, or reloader; fix that specific issue.","Verify the config file exists, is valid YAML matching EndpointConfig, and passes strict-mode rules before startup.","As a quick unblock, switch to static --endpoint flags to confirm endpoint setup otherwise works, then fix the file.","In k8s, ensure the ConfigMap is mounted and readable before the container entrypoint runs."],"exampleFix":"// before\n// thanos query --endpoint-config=/etc/thanos/endpoints.yaml   # file missing -> fails\n// after: validate in CI/startup\n// thanos tools bucket ... # no; instead pre-validate:// yq eval '.' /etc/thanos/endpoints.yaml > /dev/null && exec thanos query --endpoint-config=/etc/thanos/endpoints.yaml","handlingStrategy":"try-catch","validationCode":"func preflight(cfgPath string) error { if cfgPath == \"\" { return nil }; b, err := os.ReadFile(cfgPath); if err != nil { return err }; var c EndpointConfig; if err := yaml.Unmarshal(b, &c); err != nil { return err }; return validateEndpointConfig(&c) }","typeGuard":null,"tryCatchPattern":"ep, err := setupEndpointSet(ctx, g, logger, reg, ..., configFile)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to load config initially\") {\n        log.Fatalf(\"endpoint setup failed at startup: %v\", err)\n    }\n    return err\n}","preventionTips":["Run a config preflight check in the container entrypoint before exec thanos.","Keep endpoint configs versioned and validated in CI.","Test startup with `thanos query --endpoint-config=... ` in staging after upgrades.","Ensure mounted secrets/configs are readable by the process user."],"tags":["config","startup","thanos","endpoints"],"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"}