goharbor/harbor · error
the name of the namespace cannot be null
Error message
the name of the namespace cannot be null
What it means
Returned by the Quay adapter's PrepareForPush (src/pkg/reg/adapter/quay/adapter.go:164) when resource.Metadata.Repository.Name is the empty string. The adapter splits the name on "/" and takes paths[0] as the Quay namespace to create; an empty name yields an empty namespace, which the guard rejects before calling Quay's API.
Source
Thrown at src/pkg/reg/adapter/quay/adapter.go:164
// PrepareForPush does the prepare work that needed for pushing/uploading the resource
// eg: create the namespace or repository
func (a *adapter) PrepareForPush(resources []*model.Resource) error {
if !a.autoCreateNs {
return nil
}
namespaces := []string{}
for _, resource := range resources {
if resource == nil {
return errors.New("the resource cannot be null")
}
if resource.Metadata == nil {
return errors.New("the metadata of resource cannot be null")
}
if resource.Metadata.Repository == nil {
return errors.New("the namespace of resource cannot be null")
}
if len(resource.Metadata.Repository.Name) == 0 {
return errors.New("the name of the namespace cannot be null")
}
paths := strings.Split(resource.Metadata.Repository.Name, "/")
namespace := paths[0]
namespaces = append(namespaces, namespace)
}
for _, namespace := range namespaces {
err := a.createNamespace(&model.Namespace{
Name: namespace,
})
if err != nil {
return fmt.Errorf("create namespace '%s' in Quay error: %v", namespace, err)
}
log.Debugf("namespace %s created", namespace)
}
return nil
}
View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Ensure Name is a non-empty 'namespace/repository' string before the call.
- Pre-validate with the helper below to report the offending index.
- Test name-computation logic (rules/filters) against empty inputs.
- Log resource.Metadata.Repository at the boundary when diagnosing replication failures.
Example fix
// before
Repository: &model.Repository{},
// after
Repository: &model.Repository{Name: "myteam/" + base}, // ensure non-empty 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 hasNonEmptyRepoName(rs []*model.Resource) bool {
for _, r := range rs {
if r == nil || r.Metadata == nil || r.Metadata.Repository == nil || r.Metadata.Repository.Name == "" {
return false
}
}
return true
} 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
- Set Repository.Name explicitly from the source repository.
- Test template/override code for empty outputs.
- Validate the slice at the boundary.
When it happens
Trigger: Calling quay PrepareForPush with a Repository struct whose Name was never set or was cleared by an override/template step.
Common situations: Destination repository templating that evaluates to empty; struct copies that drop Name; fixtures with &model.Repository{}; upstream data where the repository name failed to propagate during fetch.
Related errors
- the name of namespace cannot be null
- the resource cannot be null
- the metadata of resource cannot be null
- the namespace of resource cannot be null
- [tencent-tcr.PrepareForPush] the name of the namespace canno
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/32668b5947212b06.
Report an issue: GitHub.