{"record":{"id":"7d8da380293af863","repo":"goharbor/harbor","slug":"failed-to-create-request-v","errorCode":null,"errorMessage":"failed to create request: %v","messagePattern":"failed to create request: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/health/checker.go","lineNumber":44,"sourceCode":"\t\"github.com/beego/beego/v2/client/orm\"\n\t\"github.com/docker/distribution/health\"\n\n\thttputil \"github.com/goharbor/harbor/src/common/http\"\n\t\"github.com/goharbor/harbor/src/common/utils\"\n\t\"github.com/goharbor/harbor/src/lib/cache\"\n\t\"github.com/goharbor/harbor/src/lib/config\"\n\t\"github.com/goharbor/harbor/src/lib/errors\"\n\t\"github.com/goharbor/harbor/src/lib/log\"\n)\n\n// HTTPStatusCodeHealthChecker implements a Checker to check that the HTTP status code\n// returned matches the expected one\nfunc HTTPStatusCodeHealthChecker(method string, url string, header http.Header,\n\ttimeout time.Duration, statusCode int) health.Checker {\n\treturn health.CheckFunc(func() error {\n\t\treq, err := http.NewRequest(method, url, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create request: %v\", err)\n\t\t}\n\t\tfor key, values := range header {\n\t\t\tfor _, value := range values {\n\t\t\t\treq.Header.Add(key, value)\n\t\t\t}\n\t\t}\n\n\t\tclient := httputil.NewClient(&http.Client{\n\t\t\tTransport: httputil.GetHTTPTransport(),\n\t\t\tTimeout:   timeout,\n\t\t})\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to check health: %v\", err)\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tif resp.StatusCode != statusCode {\n\t\t\tdata, err := io.ReadAll(resp.Body)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/health/checker.go#L26-L62","documentation":"Error \"failed to create request: %v\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/controller/health/checker.go:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}