goharbor/harbor · error · lib/errors.Error

http status code: %d, body: %s

Error message

http status code: %d, body: %s

What it means

Error "http status code: %d, body: %s" thrown in goharbor/harbor.

Source

Thrown at src/pkg/registry/client.go:669

	}
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		defer resp.Body.Close()
		body, err := io.ReadAll(resp.Body)
		if err != nil {
			return nil, err
		}
		code := errors.GeneralCode
		switch resp.StatusCode {
		case http.StatusUnauthorized:
			code = errors.UnAuthorizedCode
		case http.StatusForbidden:
			code = errors.ForbiddenCode
		case http.StatusNotFound:
			code = errors.NotFoundCode
		case http.StatusTooManyRequests:
			code = errors.RateLimitCode
		}
		return nil, errors.New(nil).WithCode(code).
			WithMessagef("http status code: %d, body: %s", resp.StatusCode, string(body))
	}
	return resp, nil
}

func (c *client) ListReferrers(repository, digest string, rawQuery string) (*v1.Index, map[string][]string, error) {
	remoteURL := buildReferrersURL(c.url, repository, digest, rawQuery)
	req, err := http.NewRequest(http.MethodGet, remoteURL, nil)
	if err != nil {
		return nil, nil, err
	}
	log.Debugf("upstream url %v", remoteURL)

	if c.authorizer == nil {
		log.Debug("registry client authorizer is nil") // only log this case, not an error
	}

	resp, err := c.do(req)

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/pkg/registry/client.go:669 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/54c607c247afb904. Report an issue: GitHub.