goharbor/harbor · error
no credential data provided
Error message
no credential data provided
What it means
BaseHandler.Authorize (shared by all auth handlers in the P2P preheat provider package) rejects the call when the *http.Request is nil, or when the *Credential is nil / has a nil Data map. It is the first gate every mode-specific handler (BASIC, OAUTH, CUSTOM) runs before checking its own fields, so a nil credential masquerades as whichever mode error the outer handler would add — here, plain 'no credential data provided'.
Source
Thrown at src/pkg/p2p/preheat/provider/auth/handler.go:50
Mode() string
}
// BaseHandler provides some basic functions like validation.
type BaseHandler struct{}
// Mode implements @Handler.Mode
func (b *BaseHandler) Mode() string {
return "BASE"
}
// Authorize implements @Handler.Authorize
func (b *BaseHandler) Authorize(req *http.Request, cred *Credential) error {
if req == nil {
return errors.New("nil request cannot be authorized")
}
if cred == nil || cred.Data == nil {
return errors.New("no credential data provided")
}
return nil
}
View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Ensure the preheat instance carries a non-empty auth_info appropriate for its auth_mode (BASIC: username/password pair; OAUTH: token key; CUSTOM: header key/value).
- If no auth is required, set auth_mode "NONE" so the none-handler skips data entirely.
- In Go code, guard before calling: if req == nil || cred == nil || len(cred.Data) == 0 { return errors.New("credential data required") }.
Example fix
// Go: before
client.Authorize(req, nil)
// after
if cred == nil || len(cred.Data) == 0 {
return errors.New("credential data required")
}
client.Authorize(req, cred) Defensive patterns
Strategy: type-guard
Validate before calling
// Go: guard before calling Authorize
if req == nil || cred == nil || len(cred.Data) == 0 {
return errors.New("credential data required")
} Type guard
// Go
func hasAuthData(req *http.Request, cred *auth.Credential) bool {
return req != nil && cred != nil && cred.Data != nil && len(cred.Data) > 0
} Try / catch
This is a programming-contract error, not a runtime condition to retry: fix the caller to pass a non-nil request and a credential with data (or switch the instance to NONE auth), then re-run.
Prevention
- Never construct provider clients with nil credentials; derive them from instance metadata with defaults.
- Default auth_mode to NONE when instances are registered without auth_info.
- Unit-test handler wiring with empty-instance fixtures.
When it happens
Trigger: Calling provider.Client methods with a nil Credential (instance with no auth configured but code path still calling Authorize); passing a Credential whose Data map was never populated (auth_info absent on the instance); constructing handlers directly in Go code with a nil request.
Common situations: Instances registered without any auth_info at all (empty map or omitted) while the client still routes through an auth handler; edge cases in provider drivers that build credentials from empty instance metadata; unit tests instantiating handlers without fixtures.
Related errors
- Unauthorized
- nil request
- missing username and/or password
- missing custom token/key data
- missing OAuth token
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/96d8dc3ab05e4260.
Report an issue: GitHub.