goharbor/harbor · error
empty digest to get report data
Error message
empty digest to get report data
What it means
Returned by basicManager.GetBy when the digest argument is empty. GetBy queries reports filtered by digest (optionally registration UUID and mime types); the digest is the mandatory primary filter and an empty value is rejected before the DAO query is built.
Source
Thrown at src/pkg/scan/report/manager.go:167
return err
}
query := q.Query{Keywords: q.KeyWords{"uuid": uuid}}
count, err := bm.dao.DeleteMany(ctx, query)
if err != nil {
return err
}
if count == 0 {
return errors.Errorf("no report with uuid %s deleted", uuid)
}
return nil
}
// GetBy ...
func (bm *basicManager) GetBy(ctx context.Context, digest string, registrationUUID string, mimeTypes []string) ([]*scan.Report, error) {
if len(digest) == 0 {
return nil, errors.New("empty digest to get report data")
}
kws := make(map[string]any)
kws["digest"] = digest
if len(registrationUUID) > 0 {
kws["registration_uuid"] = registrationUUID
}
if len(mimeTypes) > 0 {
kws["mime_type__in"] = mimeTypes
}
// Query all
query := &q.Query{
PageNumber: 0,
Keywords: kws,
}
return bm.dao.List(ctx, query)
}View on GitHub (pinned to 7b2fd08cc5)
Solutions
- Resolve and validate the artifact digest (format and non-empty) before querying reports
- Return 400 Bad Request at the API boundary when the digest param is missing
- Check the caller chain for the step that dropped the digest value
Example fix
// before
reports, err := bm.GetBy(ctx, digest, "", mimes) // digest == ""
// after
if len(digest) == 0 {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("artifact digest is required")
}
reports, err := bm.GetBy(ctx, digest, "", mimes) Defensive patterns
Strategy: validation
Validate before calling
if len(digest) == 0 {
return nil, errors.New(nil).WithCode(errors.BadRequestCode).
WithMessage("digest is required to query reports")
}
reports, err := bm.GetBy(ctx, digest, registrationUUID, mimeTypes) Type guard
func isValidDigest(d string) bool {
return len(d) > 0 && strings.HasPrefix(d, "sha256:") && len(d) == len("sha256:")+64
} Prevention
- Validate digest format at the request boundary before any report query
- Fail loudly when an upstream artifact lookup returns an empty digest
- Centralize digest parsing so empty values never reach managers
When it happens
Trigger: Calling GetBy(ctx, "", regUUID, mimes) from an artifact handler where the digest was not resolved; request paths where the artifact reference arrived empty after URL parsing; code passing digest before it is set.
Common situations: API handlers trusting request params without validation; artifact lookups failing upstream and the empty result flowing into report queries; tests calling GetBy with placeholders.
Related errors
- File {} not exist
- Internal dir for tls {} not exist
- nil scan report object
- malformed scan report object
- missing uuid
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/edc534904b9f6a8d.
Report an issue: GitHub.