goharbor/harbor · error

invalid response challenges

Error message

invalid response challenges

What it means

buildTokenAPI probes the registry's /v2/ endpoint with an unauthenticated GET and the response carries no WWW-Authenticate challenges, so the token realm for the Azure CR OAuth flow cannot be discovered and the authorizer cannot proceed.

Solutions

  1. Confirm the Azure container registry URL and that the endpoint is reachable/returns 401 with challenges
  2. Retry after checking network/proxy configuration stripping auth headers
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/pkg/reg/adapter/azurecr/auth.go:134 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/e3ca21dca43a05ad. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/reg/adapter/azurecr/auth.go:134

	return nil
}

// buildTokenAPI builds token request API path.
func (a *authorizer) buildTokenAPI(u *url.URL) (*url.URL, error) {
	v2URL, err := url.Parse(u.Scheme + "://" + u.Host + "/v2/")
	if err != nil {
		return nil, err
	}

	resp, err := a.client.Get(v2URL.String())
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	challenges := challenge.ResponseChallenges(resp)
	if len(challenges) == 0 {
		return nil, errors.New("invalid response challenges")
	}
	cm := map[string]challenge.Challenge{}
	for _, challenge := range challenges {
		cm[challenge.Scheme] = challenge
	}

	challenge, exist := cm["bearer"]
	if !exist {
		return nil, errors.New("no bearer challenge found")
	}

	tokenURL, err := url.Parse(challenge.Parameters["realm"])
	if err != nil {
		return nil, err
	}

	query := tokenURL.Query()
	query.Add("service", challenge.Parameters["service"])

View on GitHub (pinned to 7b2fd08cc5)