{"record":{"id":"0e1d1e6ad7e0d83a","repo":"goharbor/harbor","slug":"received-unexpected-status-code-d-s","errorCode":null,"errorMessage":"received unexpected status code: %d %s","messagePattern":"received unexpected status code: (.+?) (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/health/checker.go","lineNumber":66,"sourceCode":"\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)\n\t\t\tif err != nil {\n\t\t\t\tlog.Debugf(\"failed to read response body: %v\", err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"received unexpected status code: %d %s\", resp.StatusCode, string(data))\n\t\t}\n\n\t\treturn nil\n\t})\n}\n\ntype updater struct {\n\tsync.Mutex\n\tstatus error\n}\n\nfunc (u *updater) Check() error {\n\tu.Lock()\n\tdefer u.Unlock()\n\n\treturn u.status\n}\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/health/checker.go#L48-L84","documentation":"Error from HTTPStatusCodeHealthChecker: the probe reached the endpoint but the response status code differs from the expected one configured at checker construction. The message includes the actual code and as much of the response body as could be read to aid diagnosis.","triggerScenarios":"Thrown at src/controller/health/checker.go:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the target service - a 5xx indicates it is unhealthy.","Verify the expected statusCode configured for the checker matches the endpoint's contract.","Inspect the response body in the message for the service's own error detail."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","contentChangedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}