{"record":{"id":"b50ea08c984d7f2e","repo":"hashicorp/nomad","slug":"config-http-client-must-be-set","errorCode":null,"errorMessage":"config HTTP Client must be set","messagePattern":"config HTTP Client must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/api.go","lineNumber":451,"sourceCode":"\t// apply timeout\n\tntr.DialContext = (&net.Dialer{\n\t\tTimeout:   t,\n\t\tKeepAlive: 30 * time.Second,\n\t}).DialContext\n\n\t// clone http client with new transport\n\tnc := *httpClient\n\tnc.Transport = ntr\n\treturn &nc, nil\n}\n\n// ConfigureTLS applies a set of TLS configurations to the HTTP client.\nfunc ConfigureTLS(httpClient *http.Client, tlsConfig *TLSConfig) error {\n\tif tlsConfig == nil {\n\t\treturn nil\n\t}\n\tif httpClient == nil {\n\t\treturn errors.New(\"config HTTP Client must be set\")\n\t}\n\n\tvar clientCert tls.Certificate\n\tfoundClientCert := false\n\tif tlsConfig.ClientCert != \"\" || tlsConfig.ClientKey != \"\" {\n\t\tif tlsConfig.ClientCert != \"\" && tlsConfig.ClientKey != \"\" {\n\t\t\tvar err error\n\t\t\tclientCert, err = tls.LoadX509KeyPair(tlsConfig.ClientCert, tlsConfig.ClientKey)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfoundClientCert = true\n\t\t} else {\n\t\t\treturn errors.New(\"Both client cert and client key must be provided\")\n\t\t}\n\t} else if len(tlsConfig.ClientCertPEM) != 0 || len(tlsConfig.ClientKeyPEM) != 0 {\n\t\tif len(tlsConfig.ClientCertPEM) != 0 && len(tlsConfig.ClientKeyPEM) != 0 {\n\t\t\tvar err error","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/api.go#L433-L469","documentation":"Guard error in ConfigureTLS: TLS configuration was supplied but the *http.Client is nil, so TLS settings cannot be applied to any transport. The input at fault is a nil httpClient paired with a non-nil tlsConfig.","triggerScenarios":"Thrown at api/api.go:451 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Initialize Config.HTTPClient with a valid *http.Client before calling ConfigureTLS/NewClient","Skip ConfigureTLS when no TLS config is needed (nil tlsConfig is allowed)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}