{"record":{"id":"edc273a8ea675da9","repo":"goharbor/harbor","slug":"missing-registration-name","errorCode":null,"errorMessage":"missing registration name","messagePattern":"missing registration name","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/pkg/scan/dao/scanner/model.go","lineNumber":106,"sourceCode":"\n// ToJSON marshals registration to JSON data\nfunc (r *Registration) ToJSON() (string, error) {\n\tdata, err := json.Marshal(r)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(data), nil\n}\n\n// Validate registration\nfunc (r *Registration) Validate(checkUUID bool) error {\n\tif checkUUID && len(r.UUID) == 0 {\n\t\treturn errors.New(\"malformed endpoint\")\n\t}\n\n\tif len(r.Name) == 0 {\n\t\treturn errors.New(\"missing registration name\")\n\t}\n\n\turl, err := lib.ValidateHTTPURL(r.URL)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"scanner registration validate\")\n\t}\n\tr.URL = url\n\n\tif len(r.Auth) > 0 &&\n\t\tr.Auth != auth.Basic &&\n\t\tr.Auth != auth.Bearer &&\n\t\tr.Auth != auth.APIKey {\n\t\treturn errors.Errorf(\"auth type %s is not supported\", r.Auth)\n\t}\n\n\tif len(r.Auth) > 0 && len(r.AccessCredential) == 0 {\n\t\treturn errors.Errorf(\"access_credential is required for auth type %s\", r.Auth)\n\t}","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/scan/dao/scanner/model.go#L88-L124","documentation":"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.","triggerScenarios":"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.","commonSituations":"curl payloads missing the name key; Terraform/Ansible modules omitting name; automated scanner onboarding scripts that only set URL and auth.","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"],"exampleFix":"// before\nreg.Name = \"\"\nerr := reg.Validate(false)\n\n// after\nreg.Name = \"Trivy adapter\"\nerr := reg.Validate(false)","handlingStrategy":"validation","validationCode":"if len(reg.Name) == 0 {\n    return errors.New(\"scanner registration name is required\")\n}\nerr := reg.Validate(false)","typeGuard":"func hasName(r *scanner.Registration) bool {\n    return r != nil && len(strings.TrimSpace(r.Name)) > 0\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["scanner","registration","required-field","validation"],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}