{"record":{"id":"cfd56b8cf9b04cb3","repo":"thanos-io/thanos","slug":"failed-to-create-query-client-w","errorCode":null,"errorMessage":"failed to create query client: %w","messagePattern":"failed to create query client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":407,"sourceCode":"\t\tqueryClients    []*clientconfig.HTTPClient\n\t\tpromClients     []*promclient.Client\n\t\tgrpcEndpointSet *query.EndpointSet\n\t\tgrpcEndpoints   []string\n\t)\n\n\tqueryClientMetrics := extpromhttp.NewClientMetrics(extprom.WrapRegistererWith(prometheus.Labels{\"client\": \"query\"}, reg))\n\n\tfor _, cfg := range queryCfg {\n\t\tif cfg.HTTPConfig.NotEmpty() {\n\t\t\tcfg.HTTPConfig.HTTPClientConfig.ClientMetrics = queryClientMetrics\n\t\t\tc, err := clientconfig.NewHTTPClient(cfg.HTTPConfig.HTTPClientConfig, \"query\")\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create HTTP query client: %w\", err)\n\t\t\t}\n\t\t\tc.Transport = tracing.HTTPTripperware(logger, c.Transport)\n\t\t\tqueryClient, err := clientconfig.NewClient(logger, cfg.HTTPConfig.EndpointsConfig, c, queryProvider.Clone())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create query client: %w\", err)\n\t\t\t}\n\t\t\tqueryClients = append(queryClients, queryClient)\n\t\t\tpromClients = append(promClients, promclient.NewClient(queryClient, logger, \"thanos-rule\"))\n\t\t\t// Discover and resolve query addresses.\n\t\t\taddDiscoveryGroups(g, queryClient, conf.query.dnsSDInterval, logger)\n\t\t}\n\n\t\tif cfg.GRPCConfig != nil {\n\t\t\tgrpcEndpoints = append(grpcEndpoints, cfg.GRPCConfig.EndpointAddrs...)\n\t\t}\n\t}\n\n\tif len(grpcEndpoints) > 0 {\n\t\tdialOpts, err := extgrpc.StoreClientGRPCOpts(\n\t\t\tlogger,\n\t\t\treg,\n\t\t\ttracer,\n\t\t)","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L389-L425","documentation":"This error is returned when clientconfig.NewClient fails while assembling the query client from the endpoints config and the already-built HTTP client. runRule returns it inside the per-queryCfg loop after the HTTP client was created successfully. It indicates the endpoints/DNS provider combination is invalid rather than an HTTP/TLS problem.","triggerScenarios":"clientconfig.NewClient(logger, cfg.HTTPConfig.EndpointsConfig, c, queryProvider.Clone()) errors for a config entry — usually an endpoints list with invalid URLs or unsupported scheme for the client.","commonSituations":"Endpoints entry missing scheme or containing an address NewClient cannot parse; mixing static and file_sd endpoint configs incorrectly; empty endpoints list combined with config that NotEmpty() treats as present.","solutions":["Inspect the endpoints section of the failing query config entry; fix URL parsing issues (scheme, host, port).","Check file_sd configs referenced in endpoints exist and are readable.","Validate the whole config with clientconfig.LoadConfigs standalone to get the exact sub-error.","Confirm DNS SRV/MX/etc. sd_configs use resolvable names."],"exampleFix":"// before\nendpoints:\n  - query-svc  # no scheme\n// after\nendpoints:\n  - http://query-svc:9090","handlingStrategy":"try-catch","validationCode":"for _, e := range cfg.Endpoints {\n    if _, err := url.Parse(e.URL); err != nil {\n        return fmt.Errorf(\"bad endpoint url %q: %w\", e.URL, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := clientconfig.NewClient(logger, cfg.HTTPConfig.EndpointsConfig, c, provider.Clone()); err != nil {\n    logger.Error(\"query client build failed\", \"err\", err, \"endpoints\", cfg.HTTPConfig.EndpointsConfig)\n    return err\n}","preventionTips":["Validate endpoints URLs with url.Parse in CI.","Keep one endpoints entry style (static vs file_sd) consistent.","Log the failing endpoints section when wrapping errors."],"tags":["thanos","client","config","startup"],"backgroundTag":"invalid-url","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"}