{"record":{"id":"01fd9796020be1df","repo":"goharbor/harbor","slug":"unknown","errorCode":"UNKNOWN","errorMessage":"internal server error","messagePattern":"internal server error","errorType":"http","errorClass":"errors.Error","httpStatus":500,"severity":"error","filePath":"src/lib/http/error.go","lineNumber":59,"sourceCode":"\t\terrors.ConflictCode:                    http.StatusConflict,\n\t\terrors.PreconditionCode:                http.StatusPreconditionFailed,\n\t\terrors.ViolateForeignKeyConstraintCode: http.StatusPreconditionFailed,\n\t\terrors.PROJECTPOLICYVIOLATION:          http.StatusPreconditionFailed,\n\t\terrors.GeneralCode:                     http.StatusInternalServerError,\n\t\terrors.RequestEntityTooLargeCode:       http.StatusRequestEntityTooLarge,\n\t}\n)\n\n// SendError tries to parse the HTTP status code from the specified error, envelops it into\n// an error array as the error payload and returns the code and payload to the response.\n// And the error is logged as well\nfunc SendError(w http.ResponseWriter, err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tstatusCode, errPayload, stackTrace := apiError(err)\n\t// the error detail is logged only, and will not be sent to the client to avoid leaking server information\n\tif statusCode >= http.StatusInternalServerError {\n\t\tlog.Errorf(\"%s %s\", errPayload, stackTrace)\n\t\terr = errors.New(nil).WithCode(errors.GeneralCode).WithMessage(\"internal server error\")\n\t\terrPayload = errors.NewErrs(err).Error()\n\t} else {\n\t\t// only log the error whose status code < 500 when debugging to avoid log flooding\n\t\tlog.Debug(errPayload)\n\t}\n\tw.WriteHeader(statusCode)\n\tfmt.Fprintln(w, errPayload)\n}\n\n// generates the HTTP status code based on the specified error,\n// envelops the error into an error array as the payload and return them\nfunc apiError(err error) (statusCode int, errPayload, stackTrace string) {\n\tcode := 0\n\tvar openAPIErr openapi.Error\n\tif errors.As(err, &openAPIErr) {\n\t\t// Before executing operation handler, go-swagger will bind a parameters object to a request and validate the request,\n\t\t// it will return directly when bind and validate failed.\n\t\t// The response format of the default ServeError implementation does not match the internal error response format.","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/lib/http/error.go#L41-L77","documentation":"Error \"internal server error\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/lib/http/error.go:59 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"}