goharbor/harbor · error

scan request: invalid registry

Error message

scan request: invalid registry

What it means

Validation in ScanRequest.Validate: Registry is nil or its URL is empty, so the scan request does not say which registry to scan and cannot be dispatched to an adapter.

Solutions

  1. Populate ScanRequest.Registry with the (internal) registry URL and auth hints
  2. Verify the request builder propagated the registry settings
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/pkg/scan/rest/v1/models.go:234 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/f383c9f5fce20013. Report an issue: GitHub.

Appendix: source

Thrown at src/pkg/scan/rest/v1/models.go:234

	return json.Unmarshal([]byte(jsonData), s)
}

// ToJSON marshals ScanRequest to JSON data
func (s *ScanRequest) ToJSON() (string, error) {
	data, err := json.Marshal(s)
	if err != nil {
		return "", err
	}

	return string(data), nil
}

// Validate ScanRequest
func (s *ScanRequest) Validate() error {
	if s.Registry == nil ||
		len(s.Registry.URL) == 0 {
		return errors.New("scan request: invalid registry")
	}

	if s.Artifact == nil ||
		len(s.Artifact.Digest) == 0 ||
		len(s.Artifact.Repository) == 0 ||
		len(s.Artifact.MimeType) == 0 {
		return errors.New("scan request: invalid artifact")
	}

	return nil
}

// ScanResponse represents the response returned by the scanner adapter after scan request successfully
// submitted.
type ScanResponse struct {
	// e.g: 3fa85f64-5717-4562-b3fc-2c963f66afa6
	ID string `json:"id"`
}

View on GitHub (pinned to 7b2fd08cc5)