#24007·harbor

GC leaves orphan SBOM accessories, scan reports and executions behind: jobservice does not register the sbom accessory type nor the event handlers

Author: romain-rossiCreated Sep 25, 2026Updated Sep 28, 2026

Expected behavior and actual behavior:

Expected: when garbage collection deletes an untagged artifact (delete_untagged: true), the result is the same as deleting it through the API: its hard accessories (SBOM) are deleted with it, and the DeleteArtifact event is handled (internal.ArtifactEventHandler.onDelete removes the scan reports, the IMAGE_SCAN executions and the sbom_report; auditlog.Handler writes the audit entry).

Actual: GC runs in jobservice, and src/jobservice/main.go does not import what src/core/main.go imports for this:

  • _ "github.com/goharbor/harbor/src/pkg/accessory/model/sbom": jobservice registers base, cosign, notation, nydus and subject, but not sbom;
  • _ "github.com/goharbor/harbor/src/controller/event/handler", and no notification.Init().

GC calls the same artCtl.Delete() as core (garbage_collection.go, untagged loop). In jobservice:

  1. populateAccessories cannot build the SBOM accessory, so art.Accessories is empty and deleteDeeply never recurses into it. The jobservice log shows, for every untagged artifact that has an SBOM:
    [ERROR] [/controller/artifact/controller.go:804]: failed to list accessories of artifact 124514: accessory type sbom.harbor not support
    The subject is deleted and the SBOM accessory artifact is left behind without its subject. Later GC runs do not remove it either (they are what accumulated the numbers below).
  2. The DeleteArtifactEventMetadata raised by deleteDeeply is added with notification.AddEvent but no handler is subscribed to TopicDeleteArtifact in that process. So nothing removes the sbom_report rows, the scan reports / report_vulnerability_record links, or the IMAGE_SCAN executions and tasks of the deleted artifact, and no audit log entry is written for the deletion.

Side note, not specific to GC: onDelete only deletes executions of vendor type IMAGE_SCAN (DeleteByVendor(ctx, job.ImageScanJobVendorType, id)), so the SBOM executions of a deleted artifact stay behind even when core deletes it through the API. We saw it on the reproduction below.

Deleting the same orphan SBOM through core's API (DELETE /api/v2.0/projects/{p}/repositories/{r}/artifacts/{digest}) cleans everything up (accessory, artifact, sbom_report, audit entry), and the next GC then frees its blobs. That is our workaround, run weekly.

Everything above is still true on main (checked at e5e0e72c74, 2026-09-24); only the error text changed there (unsupported accessory type).

Scale on our production registry (projects with automatic SBOM generation and automatic scan on push, daily GC with delete_untagged), found on 2026-09-25:

  • 8,719 orphan SBOM artifacts;
  • 22,639 IMAGE_SCAN / SBOM executions and 22,640 tasks pointing to deleted artifacts (both vendor types together; the SBOM ones partly come from the side note above);
  • 41 orphan sbom_report rows.

After deleting the SBOMs through the API, the next GC purged 8,734 manifests and 17,492 blobs and freed 19.8 GB. The same GC run immediately left a new orphan SBOM behind.

Steps to reproduce the problem:

  1. In a test project, get an artifact repo:v1 (we copied one: POST /projects/{p}/repositories/repo/artifacts?from=...).
  2. Scan it and generate its SBOM: POST .../artifacts/v1/scan with {"scan_type":{"scan_type":"vulnerability"}}, then with "sbom". The SBOM accessory appears under the artifact.
  3. Make the artifact untagged: DELETE .../artifacts/{digest}/tags/v1.
  4. Run GC with "Allow garbage collection on untagged artifacts".
  5. Observe:
    • the jobservice log shows accessory type sbom.harbor not support for the untagged artifact;
    • the untagged artifact is gone, but its SBOM artifact is still in the repository, without its subject;
    • its sbom_report row and its IMAGE_SCAN / SBOM executions (execution.vendor_id = the deleted artifact id) and their tasks are still there;
    • no audit log entry for the deletion (the audit log has the tag deletion of step 3, then nothing until step 6).
  6. Delete the orphan SBOM through the API: it and its sbom_report go, with an audit entry; its SBOM execution stays (side note).

Reproduced on a disposable project of our test instance on 2026-09-25.

Versions:

  • harbor version: v2.15.2 (Helm chart 1.19.2)
  • Kubernetes v1.31.8 (Helm install, no docker-compose)
  • external PostgreSQL 18 (CloudNativePG)

Additional context:

Related: #17927 (one of the symptoms, growth of report_vulnerability_record, closed as stale). #23310 / #23319 look different (rescan churn, not deletion).

Suggested fix: make jobservice register the same accessory types as core (import pkg/accessory/model/sbom), and either register the event handlers in jobservice (controller/event/handler + notification.Init()) or make GC delegate untagged artifact deletion to core. Happy to test a patch.