goharbor/harbor · error

the repository of resource cannot be null

Error message

the repository of resource cannot be null

What it means

Nil-guard in harbor base Adapter.PrepareForPush: resource.Metadata.Repository is nil, so no repository name (and hence project) can be derived for creating the Harbor project.

Solutions

  1. Set the Repository field of the resource metadata
  2. Check the converter that maps source artifacts to transfer resources
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/pkg/reg/adapter/harbor/base/adapter.go:151 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/ec9f8e1b8483b86a. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/reg/adapter/harbor/base/adapter.go:151

			Style:  model.FilterStyleTypeList,
			Values: labels,
		})

	return info, nil
}

// PrepareForPush creates projects
func (a *Adapter) PrepareForPush(resources []*model.Resource) error {
	projects := map[string]*Project{}
	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 repository of resource cannot be null")
		}
		if len(resource.Metadata.Repository.Name) == 0 {
			return errors.New("the name of the repository cannot be null")
		}

		paths := strings.Split(resource.Metadata.Repository.Name, "/")
		projectName := paths[0]
		// handle the public properties
		metadata := abstractPublicMetadata(resource.Metadata.Repository.Metadata)
		pro, exist := projects[projectName]
		if exist {
			metadata = mergeMetadata(pro.Metadata, metadata)
		}
		projects[projectName] = &Project{
			Name:     projectName,
			Metadata: metadata,
		}
	}

View on GitHub (pinned to 7b2fd08cc5)