goharbor/harbor · error

scan request: invalid artifact

Error message

scan request: invalid artifact

What it means

Validation in ScanRequest.Validate: Artifact is nil or missing one of digest, repository, or mime type — the mandatory artifact identity fields for a scan request.

Solutions

  1. Set artifact digest, repository and the artifact's media type when building the scan request
  2. Check that artifact info propagation from the controller did not drop fields
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

	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"`
}

// ErrorResponse contains error message when requests are not correctly handled.
type ErrorResponse struct {
	// Error object
	Err *Error `json:"error"`
}

View on GitHub (pinned to 7b2fd08cc5)