goharbor/harbor · error
set api key in is invalid
Error message
set api key in %s is invalid
What it means
Returned by apiKeyAuthorizer.Modify when the configured API key placement is neither 'header' nor 'query'. This is a default-branch guard after an exhaustive switch: the authorizer was constructed with an unsupported APIKeyIn value, so no auth material can be attached to the request. The input at fault is the 'in' field set at construction time.
Solutions
- Construct the authorizer with APIKeyInHeader or APIKeyInQuery only
- If a new placement is needed, extend the switch in Modify to handle it
- Validate the 'in' value at authorizer construction to fail early
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/pkg/reg/adapter/quay/auth/apikey.go:58 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/79ad43c404ece50c.
Report an issue: GitHub.
Appendix: source
Thrown at src/pkg/reg/adapter/quay/auth/apikey.go:58
key: key,
value: value,
in: in,
}
}
// Modify implements modifier.Modifier
func (a *apiKeyAuthorizer) Modify(r *http.Request) error {
switch a.in {
case APIKeyInHeader:
r.Header.Set(a.key, a.value)
return nil
case APIKeyInQuery:
query := r.URL.Query()
query.Add(a.key, a.value)
r.URL.RawQuery = query.Encode()
return nil
}
return fmt.Errorf("set api key in %s is invalid", a.in)
}
View on GitHub (pinned to 7b2fd08cc5)