{"record":{"id":"9b51b616434b4ad1","repo":"thanos-io/thanos","slug":"parsing-http-config-yaml","errorCode":null,"errorMessage":"parsing http config YAML","messagePattern":"parsing http config YAML","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":79,"sourceCode":"func 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,\n\t\t}\n\n\t\tswitch conf.reloader.method {\n\t\tcase HTTPReloadMethod:","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L61-L97","documentation":"After obtaining the raw content, the sidecar converts it into a client-go style HTTPClientConfig via clientconfig.NewHTTPClientConfigFromYAML(httpConfContentYaml). If the content is not valid YAML or doesn't match the HTTPClientConfig schema (e.g. unknown tls_config fields), startup aborts with \"parsing http config YAML\".","triggerScenarios":"Passing an HTTP client config whose content is invalid YAML (tabs, bad indentation) or contains unknown/mistyped keys (e.g. tls_config.certificate_file instead of cert_file), so NewHTTPClientConfigFromYAML fails at cmd/thanos/sidecar.go:78.","commonSituations":"Hand-written YAML with indentation/tab errors; Prometheus-format TLS blocks copied incorrectly; JSON passed where strict YAML decoding rejects duplicate or unknown keys; schema drift between client-go versions.","solutions":["Paste the config content into a YAML linter/parser to catch syntax errors (tabs vs spaces, stray characters).","Validate keys against the prometheus/common config HTTPClientConfig schema (http_headers, tls_config with ca_file/cert_file/key_file, bearer_token, etc.).","Read the wrapped unmarshal error in the message — it names the offending key and line.","Start from a known-good minimal config like `{}` or `{\"tls_config\": {\"insecure_skip_verify\": true}}` and add fields incrementally."],"exampleFix":"// before\n{\"tls_config\": {\"certificate_file\": \"/certs/tls.crt\"}}\n// after\n{\"tls_config\": {\"cert_file\": \"/certs/tls.crt\", \"key_file\": \"/certs/tls.key\"}}","handlingStrategy":"validation","validationCode":"func validHTTPClientYAML(y string) error {\n    var cfg clientconfig.HTTPClientConfig\n    return yaml.UnmarshalStrict([]byte(y), &cfg) // same strict decode the sidecar performs\n}","typeGuard":"null","tryCatchPattern":"httpClientConfig, err := clientconfig.NewHTTPClientConfigFromYAML(httpConfContentYaml)\nif err != nil {\n    return fmt.Errorf(\"parsing http config YAML: %w (check keys against prometheus/common HTTPClientConfig schema)\", err)\n}","preventionTips":["Pre-parse your config with yaml.UnmarshalStrict into HTTPClientConfig in tests to catch unknown keys early","Avoid tabs in YAML; use spaces and validate with a YAML linter","Copy TLS/auth keys only from the prometheus/common config schema documentation"],"tags":["go","config","yaml","http-client","thanos"],"backgroundTag":"yaml-parse-error","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"}