{"record":{"id":"9d4e0db807645be0","repo":"goharbor/harbor","slug":"volcengine-cr-prepareforpush-the-name-of-the-nam","errorCode":null,"errorMessage":"[volcengine-cr.PrepareForPush] the name of the namespace cannot be null","messagePattern":"\\[volcengine-cr\\.PrepareForPush\\] the name of the namespace cannot be null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/reg/adapter/volcenginecr/adapter.go","lineNumber":144,"sourceCode":"\t\t\tmodel.TriggerTypeScheduled,\n\t\t},\n\t}\n\treturn\n}\n\nfunc (a *adapter) PrepareForPush(resources []*model.Resource) (err error) {\n\tfor _, resource := range resources {\n\t\tif resource == nil {\n\t\t\treturn errors.New(\"the resource cannot be null\")\n\t\t}\n\t\tif resource.Metadata == nil {\n\t\t\treturn errors.New(\"[volcengine-cr.PrepareForPush] the metadata of resource cannot be null\")\n\t\t}\n\t\tif resource.Metadata.Repository == nil {\n\t\t\treturn errors.New(\"[volcengine-cr.PrepareForPush] the namespace of resource cannot be null\")\n\t\t}\n\t\tif len(resource.Metadata.Repository.Name) == 0 {\n\t\t\treturn errors.New(\"[volcengine-cr.PrepareForPush] the name of the namespace cannot be null\")\n\t\t}\n\t\tvar paths = strings.Split(resource.Metadata.Repository.Name, \"/\")\n\t\tif len(paths) < 2 {\n\t\t\treturn errors.New(\"[volcengine-cr.PrepareForPush] the name of the repository and namespace cannot be null\")\n\t\t}\n\t\tvar namespace = paths[0]\n\t\tvar repository = path.Join(paths[1:]...)\n\n\t\tlog.Debugf(\"namespace=%s\", namespace)\n\t\terr = a.createNamespace(namespace)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"PrepareForPush error :%v\", err)\n\t\t\treturn\n\t\t}\n\t\tlog.Debugf(\"namespace=%s, repository=%s\", namespace, repository)\n\t\terr = a.createRepository(namespace, repository)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"PrepareForPush error :%v\", err)","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/reg/adapter/volcenginecr/adapter.go#L126-L162","documentation":"Returned by the Volcengine CR adapter's PrepareForPush (src/pkg/reg/adapter/volcenginecr/adapter.go:144) when resource.Metadata.Repository.Name is the empty string. The adapter splits the name into namespace/repository; an empty name is rejected before the split. (Distinct from the sibling 'the name of the repository and namespace cannot be null' error at :149, which fires when the name is non-empty but contains no '/', i.e. len(paths) < 2.)","triggerScenarios":"Calling volcenginecr PrepareForPush with a Repository whose Name is \"\" — name never set or cleared by an override.","commonSituations":"Destination naming template evaluating to empty; struct copy dropping Name; placeholder fixtures; upstream fetch silently producing empty names.","solutions":["Ensure Name is non-empty AND contains a '/' (volcenginecr requires 'namespace/repository').","Pre-validate names with the helper below.","Test name-computation code paths against empty inputs.","Log resource.Metadata.Repository.Name at the boundary when triaging replication failures."],"exampleFix":"// before\nRepository: &model.Repository{},\n\n// after\nRepository: &model.Repository{Name: \"myteam/myrepo\"},","handlingStrategy":"validation","validationCode":"for i, r := range resources {\n\tif r == nil || r.Metadata == nil || r.Metadata.Repository == nil || r.Metadata.Repository.Name == \"\" {\n\t\treturn fmt.Errorf(\"resources[%d]: invalid resource\", i)\n\t}\n\tif !strings.Contains(r.Metadata.Repository.Name, \"/\") {\n\t\treturn fmt.Errorf(\"resources[%d]: name must be 'namespace/repository'\", i)\n\t}\n}","typeGuard":"func hasVolcRepoName(r *model.Resource) bool {\n\treturn r != nil && r.Metadata != nil && r.Metadata.Repository != nil &&\n\t\tstr.Contains(r.Metadata.Repository.Name, \"/\")\n\t// note: guard against empty string first; volcenginecr also rejects single-segment names\n}","tryCatchPattern":"if err := a.PrepareForPush(resources); err != nil {\n\tif strings.Contains(err.Error(), \"name of the namespace cannot be null\") {\n\t\t// empty Repository.Name: set a non-empty value and retry\n\t} else if strings.Contains(err.Error(), \"repository and namespace cannot be null\") {\n\t\t// name lacked '/': use 'namespace/repository' form\n\t}\n\treturn err\n}","preventionTips":["Set Repository.Name as 'namespace/repository' (both segments required).","Derive the name from the source repository, not templates alone.","Test naming code against empty and single-segment inputs."],"tags":["go","volcengine-cr","replication","validation","empty-string"],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}