goharbor/harbor · error · errors.Error
UNKNOWN
UNKNOWN
Error message
internal server error
What it means
Error "internal server error" thrown in goharbor/harbor.
Source
Thrown at src/lib/http/error.go:59
errors.ConflictCode: http.StatusConflict,
errors.PreconditionCode: http.StatusPreconditionFailed,
errors.ViolateForeignKeyConstraintCode: http.StatusPreconditionFailed,
errors.PROJECTPOLICYVIOLATION: http.StatusPreconditionFailed,
errors.GeneralCode: http.StatusInternalServerError,
errors.RequestEntityTooLargeCode: http.StatusRequestEntityTooLarge,
}
)
// SendError tries to parse the HTTP status code from the specified error, envelops it into
// an error array as the error payload and returns the code and payload to the response.
// And the error is logged as well
func SendError(w http.ResponseWriter, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
statusCode, errPayload, stackTrace := apiError(err)
// the error detail is logged only, and will not be sent to the client to avoid leaking server information
if statusCode >= http.StatusInternalServerError {
log.Errorf("%s %s", errPayload, stackTrace)
err = errors.New(nil).WithCode(errors.GeneralCode).WithMessage("internal server error")
errPayload = errors.NewErrs(err).Error()
} else {
// only log the error whose status code < 500 when debugging to avoid log flooding
log.Debug(errPayload)
}
w.WriteHeader(statusCode)
fmt.Fprintln(w, errPayload)
}
// generates the HTTP status code based on the specified error,
// envelops the error into an error array as the payload and return them
func apiError(err error) (statusCode int, errPayload, stackTrace string) {
code := 0
var openAPIErr openapi.Error
if errors.As(err, &openAPIErr) {
// Before executing operation handler, go-swagger will bind a parameters object to a request and validate the request,
// it will return directly when bind and validate failed.
// The response format of the default ServeError implementation does not match the internal error response format.View on GitHub (pinned to 7b2fd08cc5)
When it happens
Trigger: Thrown at src/lib/http/error.go:59 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/01fd9796020be1df.
Report an issue: GitHub.