goharbor/harbor · error
[tencent-tcr.PrepareForPush] the name of the namespace canno
Error message
[tencent-tcr.PrepareForPush] the name of the namespace cannot be null
What it means
Returned by the Tencent TCR adapter's PrepareForPush (src/pkg/reg/adapter/tencentcr/adapter.go:224) when resource.Metadata.Repository.Name is the empty string. The name is split on "/" to derive the namespace (paths[0]) and repository (paths[1:]) that the adapter creates in TCR; an empty name has no namespace segment and is rejected.
Source
Thrown at src/pkg/reg/adapter/tencentcr/adapter.go:224
},
}
return
}
func (a *adapter) PrepareForPush(resources []*model.Resource) (err error) {
log.Debugf("[tencent-tcr.PrepareForPush]")
for _, resource := range resources {
if resource == nil {
return errors.New("the resource cannot be null")
}
if resource.Metadata == nil {
return errors.New("[tencent-tcr.PrepareForPush] the metadata of resource cannot be null")
}
if resource.Metadata.Repository == nil {
return errors.New("[tencent-tcr.PrepareForPush] the namespace of resource cannot be null")
}
if len(resource.Metadata.Repository.Name) == 0 {
return errors.New("[tencent-tcr.PrepareForPush] the name of the namespace cannot be null")
}
var paths = strings.Split(resource.Metadata.Repository.Name, "/")
var namespace = paths[0]
var repository = path.Join(paths[1:]...)
log.Debugf("[tencent-tcr.PrepareForPush.createPrivateNamespace] namespace=%s", namespace)
err = a.createPrivateNamespace(namespace)
if err != nil {
return
}
log.Debugf("[tencent-tcr.PrepareForPush.createRepository] namespace=%s, repository=%s", namespace, repository)
err = a.createRepository(namespace, repository)
if err != nil {
return
}
}
returnView on GitHub (pinned to 7b2fd08cc5)
Solutions
- Ensure Name is a non-empty 'namespace/repository' string before the call.
- Pre-validate names (see validationCode) to report the exact failing index.
- Unit-test name computation against empty/edge-case inputs.
- Log resource.Metadata.Repository.Name at the pipeline boundary when triaging.
Example fix
// before
Repository: &model.Repository{},
// after
Repository: &model.Repository{Name: "myns/myrepo"}, Defensive patterns
Strategy: validation
Validate before calling
for i, r := range resources {
if r == nil || r.Metadata == nil || r.Metadata.Repository == nil || r.Metadata.Repository.Name == "" {
return fmt.Errorf("resources[%d]: invalid resource", i)
}
} Type guard
func hasRepoName(r *model.Resource) bool {
return r != nil && r.Metadata != nil &&
r.Metadata.Repository != nil && r.Metadata.Repository.Name != ""
} Try / catch
if err := a.PrepareForPush(resources); err != nil {
if strings.Contains(err.Error(), "name of the namespace cannot be null") {
// empty Repository.Name: set 'namespace/repo' and retry
}
return err
} Prevention
- Propagate the source repository name into every derived resource.
- Test name computation against empty inputs.
- Validate at the boundary with an index-reporting helper.
When it happens
Trigger: Calling tencentcr PrepareForPush with a Repository whose Name is "" — typically after a name-override produced empty or a clone dropped the field.
Common situations: Destination naming templates evaluating to empty; field dropped during struct copy; placeholder fixtures (&model.Repository{}); upstream fetch failing to set the name silently.
Related errors
- the name of namespace cannot be null
- the name of the namespace cannot be null
- the resource cannot be null
- [tencent-tcr.PrepareForPush] the metadata of resource cannot
- [tencent-tcr.PrepareForPush] the namespace of resource canno
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/13dfce0bf53e203b.
Report an issue: GitHub.