goharbor/harbor · error
missing registration name
Error message
missing registration name
What it means
Returned by scanner Registration.Validate when the Name field is empty. Every scanner registration must carry a human-readable name; the guard runs before URL/auth validation and is the first required-field check after the UUID guard.
Source
Thrown at src/pkg/scan/dao/scanner/model.go:106
// ToJSON marshals registration to JSON data
func (r *Registration) ToJSON() (string, error) {
data, err := json.Marshal(r)
if err != nil {
return "", err
}
return string(data), nil
}
// Validate registration
func (r *Registration) Validate(checkUUID bool) error {
if checkUUID && len(r.UUID) == 0 {
return errors.New("malformed endpoint")
}
if len(r.Name) == 0 {
return errors.New("missing registration name")
}
url, err := lib.ValidateHTTPURL(r.URL)
if err != nil {
return errors.Wrap(err, "scanner registration validate")
}
r.URL = url
if len(r.Auth) > 0 &&
r.Auth != auth.Basic &&
r.Auth != auth.Bearer &&
r.Auth != auth.APIKey {
return errors.Errorf("auth type %s is not supported", r.Auth)
}
if len(r.Auth) > 0 && len(r.AccessCredential) == 0 {
return errors.Errorf("access_credential is required for auth type %s", r.Auth)
}View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Include a non-empty name in the registration payload, e.g. {"name": "trivy", "url": "http://trivy:8080"}
- Validate required fields client-side before calling the scanner API
- If updating, keep the existing name unless intentionally renaming
Example fix
// before reg.Name = "" err := reg.Validate(false) // after reg.Name = "Trivy adapter" err := reg.Validate(false)
Defensive patterns
Strategy: validation
Validate before calling
if len(reg.Name) == 0 {
return errors.New("scanner registration name is required")
}
err := reg.Validate(false) Type guard
func hasName(r *scanner.Registration) bool {
return r != nil && len(strings.TrimSpace(r.Name)) > 0
} Prevention
- Require name in scanner registration forms and API clients
- Trim whitespace when reading the name from payloads
- Keep a client-side required-field checklist (name, url) for scanner onboarding
When it happens
Trigger: POST /scanners with a JSON body missing the name field; PUT update that clears the name; programmatic registration of an adapter (Trivy, etc.) without setting Name on the model.
Common situations: curl payloads missing the name key; Terraform/Ansible modules omitting name; automated scanner onboarding scripts that only set URL and auth.
Related errors
- malformed endpoint
- File {} not exist
- Internal dir for tls {} not exist
- Port number in metrics is not valid
- Jaeger Colector Endpoint or Agent host not set, must set one
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/edc273a8ea675da9.
Report an issue: GitHub.