{"record":{"id":"df9bb8c0ae640b3a","repo":"hashicorp/nomad","slug":"nil-http-client","errorCode":null,"errorMessage":"nil HTTP client","messagePattern":"nil HTTP client","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/api.go","lineNumber":398,"sourceCode":"\tif v := os.Getenv(\"NOMAD_TLS_SERVER_NAME\"); v != \"\" {\n\t\tconfig.TLSConfig.TLSServerName = v\n\t}\n\tif v := os.Getenv(\"NOMAD_SKIP_VERIFY\"); v != \"\" {\n\t\tif insecure, err := strconv.ParseBool(v); err == nil {\n\t\t\tconfig.TLSConfig.Insecure = insecure\n\t\t}\n\t}\n\tif v := os.Getenv(\"NOMAD_TOKEN\"); v != \"\" {\n\t\tconfig.SecretID = v\n\t}\n\treturn config\n}\n\n// cloneWithTimeout returns a cloned httpClient with set timeout if positive;\n// otherwise, returns the same client\nfunc cloneWithTimeout(httpClient *http.Client, t time.Duration) (*http.Client, error) {\n\tif httpClient == nil {\n\t\treturn nil, errors.New(\"nil HTTP client\")\n\t} else if httpClient.Transport == nil {\n\t\treturn nil, errors.New(\"nil HTTP client transport\")\n\t}\n\n\tif t.Nanoseconds() < 0 {\n\t\treturn httpClient, nil\n\t}\n\n\ttr, ok := httpClient.Transport.(*http.Transport)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected HTTP transport: %T\", httpClient.Transport)\n\t}\n\n\t// copy all public fields, to avoid copying transient state and locks\n\tntr := &http.Transport{\n\t\tProxy:                  tr.Proxy,\n\t\tDialContext:            tr.DialContext,\n\t\tDial:                   tr.Dial,","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/api.go#L380-L416","documentation":"Guard error in cloneWithTimeout: it fires when the caller passes a nil *http.Client to clone, meaning the Config.HTTPClient (or equivalent) was never set, so a timeout cannot be applied and no request could be made.","triggerScenarios":"Thrown at api/api.go:398 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-nil *http.Client in the api.Config before calling NewClient or node client setup","Use api.DefaultConfig() which initializes a default HTTP client"],"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"}