{"record":{"id":"a7481065bbdbe33d","repo":"thanos-io/thanos","slug":"getting-http-client-config","errorCode":null,"errorMessage":"getting http client config","messagePattern":"getting http client config","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":75,"sourceCode":"\t\"github.com/thanos-io/thanos/pkg/targets\"\n\t\"github.com/thanos-io/thanos/pkg/tls\"\n)\n\nfunc registerSidecar(app *extkingpin.App) {\n\tcmd := app.Command(component.Sidecar.String(), \"Sidecar for Prometheus server.\")\n\tconf := &sidecarConfig{}\n\tconf.registerFlag(cmd)\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {\n\n\t\tgrpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(conf.reqLogConfig)\n\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error while parsing config for request logging\")\n\t\t}\n\n\t\thttpConfContentYaml, err := conf.prometheus.httpClient.Content()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting http client config\")\n\t\t}\n\t\thttpClientConfig, err := clientconfig.NewHTTPClientConfigFromYAML(httpConfContentYaml)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"parsing http config YAML\")\n\t\t}\n\n\t\thttpClient, err := clientconfig.NewHTTPClient(*httpClientConfig, \"thanos-sidecar\")\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"Improper http client config\")\n\t\t}\n\n\t\topts := reloader.Options{\n\t\t\tHTTPClient:    *httpClient,\n\t\t\tCfgFile:       conf.reloader.confFile,\n\t\t\tCfgOutputFile: conf.reloader.envVarConfFile,\n\t\t\tWatchedDirs:   conf.reloader.ruleDirectories,\n\t\t\tWatchInterval: conf.reloader.watchInterval,\n\t\t\tRetryInterval: conf.reloader.retryInterval,","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L57-L93","documentation":"The sidecar's Setup reads the Prometheus HTTP client configuration content via conf.prometheus.httpClient.Content() (a flagext-style value holding the inline YAML/JSON for --prometheus.http-client-config style settings). If reading/obtaining that content fails, startup aborts with \"getting http client config\". This usually means the registered config flag value itself is unreadable or empty when content is required.","triggerScenarios":"The http client config flag (conf.prometheus.httpClient) was not set, is empty when content is required, or its Content() accessor fails because the registered value failed Kingpin parsing, so httpClient.Content() returns an error at cmd/thanos/sidecar.go:74.","commonSituations":"Omitting the HTTP client config flag while the deployment requires TLS/auth to reach Prometheus; passing a file path where inline content is expected (or vice versa); flag registration order issues when embedding the sidecar in custom builds.","solutions":["Check the wrapped error: it states why the config value could not be read (unset flag vs. invalid content).","Supply a valid inline YAML/JSON http client config value for the Prometheus client flag if one is required.","If no custom client config is needed, ensure the default (empty) config is accepted — avoid passing an empty string where content is mandatory.","Verify the flag is registered and parsed before Setup runs (correct Kingpin registration in custom builds)."],"exampleFix":"// before\nconf.prometheus.httpClient = nil // flag never registered/set\n// after\nregisterHTTPClientFlags(cmd, &conf.prometheus.httpClient)\n// and pass e.g.:\n//   --prometheus.http-client-config='{\"tls_config\": {\"ca_file\": \"/certs/ca.pem\"}}'","handlingStrategy":"validation","validationCode":"if conf.prometheus.httpClient == nil {\n    return errors.New(\"prometheus http client config flag not set/registered\")\n}\nif _, err := conf.prometheus.httpClient.Content(); err != nil {\n    return fmt.Errorf(\"http client config unreadable: %w\", err)\n}","typeGuard":"null","tryCatchPattern":"httpConfContentYaml, err := conf.prometheus.httpClient.Content()\nif err != nil {\n    return fmt.Errorf(\"getting http client config: %w\", err)\n}","preventionTips":["Register and set the HTTP client config flag before Setup runs","Pass inline YAML/JSON content where content is expected, not a file path","Fail fast in custom builds by calling Content() during config validation"],"tags":["go","config","startup","http-client","thanos"],"backgroundTag":"missing-config-value","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"}