GC leaves orphan SBOM accessories, scan reports and executions behind: jobservice does not register the sbom accessory type nor the event handlers
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 nonotification.Init().
GC calls the same artCtl.Delete() as core (garbage_collection.go, untagged loop). In jobservice:
populateAccessoriescannot build the SBOM accessory, soart.Accessoriesis empty anddeleteDeeplynever recurses into it. The jobservice log shows, for every untagged artifact that has an SBOM: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).[ERROR] [/controller/artifact/controller.go:804]: failed to list accessories of artifact 124514: accessory type sbom.harbor not support- The
DeleteArtifactEventMetadataraised bydeleteDeeplyis added withnotification.AddEventbut no handler is subscribed toTopicDeleteArtifactin that process. So nothing removes thesbom_reportrows, the scan reports /report_vulnerability_recordlinks, or theIMAGE_SCANexecutions 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/SBOMexecutions and 22,640 tasks pointing to deleted artifacts (both vendor types together; theSBOMones partly come from the side note above); - 41 orphan
sbom_reportrows.
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:
- In a test project, get an artifact
repo:v1(we copied one:POST /projects/{p}/repositories/repo/artifacts?from=...). - Scan it and generate its SBOM:
POST .../artifacts/v1/scanwith{"scan_type":{"scan_type":"vulnerability"}}, then with"sbom". The SBOM accessory appears under the artifact. - Make the artifact untagged:
DELETE .../artifacts/{digest}/tags/v1. - Run GC with "Allow garbage collection on untagged artifacts".
- Observe:
- the jobservice log shows
accessory type sbom.harbor not supportfor the untagged artifact; - the untagged artifact is gone, but its SBOM artifact is still in the repository, without its subject;
- its
sbom_reportrow and itsIMAGE_SCAN/SBOMexecutions (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).
- the jobservice log shows
- Delete the orphan SBOM through the API: it and its
sbom_reportgo, with an audit entry; itsSBOMexecution 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.
Source: goharbor/harbor