goharbor/harbor · error

create namespace ' ' in DockerHub error

Error message

create namespace '%s' in DockerHub error: %v

What it means

PrepareForPush tried to create each namespace derived from the pushed resource names in DockerHub and CreateNamespace returned an error; the namespace and underlying error are wrapped, aborting the push preparation.

Solutions

  1. Check Docker Hub credentials and namespace availability
  2. Look at the inner error for the exact API failure (conflict, permission)
  3. Ensure the namespace portion of repository names is valid for Docker Hub
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/a0fb94321f7a3239. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/reg/adapter/dockerhub/adapter.go:154

			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[namespace] = struct{}{}
	}

	for namespace := range namespaces {
		err := a.CreateNamespace(&model.Namespace{
			Name: namespace,
		})
		if err != nil {
			return fmt.Errorf("create namespace '%s' in DockerHub error: %v", namespace, err)
		}
		log.Debugf("namespace %s created", namespace)
	}
	return nil
}

func (a *adapter) listNamespaces() ([]string, error) {
	resp, err := a.client.Do(http.MethodGet, listNamespacePath, nil)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 7b2fd08cc5)