goharbor/harbor · error · errors.Error

BAD_REQUEST

BAD_REQUEST

Error message

empty string

What it means

Error "empty string" thrown in goharbor/harbor.

Source

Thrown at src/lib/endpoint.go:31

// limitations under the License.

package lib

import (
	"fmt"
	"net/url"
	"strings"

	"github.com/goharbor/harbor/src/lib/errors"
)

// ValidateHTTPURL checks whether the provided string is a valid HTTP URL.
// If it is, return the URL in format "scheme://host:port" to avoid the SSRF
func ValidateHTTPURL(s string) (string, error) {
	s = strings.Trim(s, " ")
	s = strings.TrimRight(s, "/")
	if len(s) == 0 {
		return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessage("empty string")
	}
	if !strings.Contains(s, "://") {
		s = "http://" + s
	}
	url, err := url.Parse(s)
	if err != nil {
		return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid URL: %s", err.Error())
	}
	if url.Scheme != "http" && url.Scheme != "https" {
		return "", errors.New(nil).WithCode(errors.BadRequestCode).WithMessagef("invalid HTTP scheme: %s", url.Scheme)
	}
	// To avoid SSRF security issue, refer to #3755 for more detail
	return fmt.Sprintf("%s://%s%s", url.Scheme, url.Host, url.Path), nil
}

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/lib/endpoint.go:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/c5878f8f3b63f18a. Report an issue: GitHub.