From 7c827be4d0dd47a3368efb41a6a5c4ac12cf7737 Mon Sep 17 00:00:00 2001 From: DmitriyLewen Date: Fri, 6 Dec 2024 12:02:03 +0600 Subject: [PATCH] fix: handle `BLOW_UNKNOWN` error --- pkg/oci/artifact.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/oci/artifact.go b/pkg/oci/artifact.go index 8ed7dcdad03d..440cbebc0979 100644 --- a/pkg/oci/artifact.go +++ b/pkg/oci/artifact.go @@ -262,6 +262,19 @@ func shouldTryOtherRepo(err error) bool { } } - // try the following artifact only if a temporary error occurs - return terr.Temporary() + // try the following artifact if a temporary error occurs + if terr.Temporary() { + return true + } + + // `GCR` periodically returns `BLOB_UNKNOWN` error. + // cf. https://github.com/aquasecurity/trivy/discussions/8020 + // In this case we need to check other repositories. + for _, e := range terr.Errors { + if e.Code == transport.BlobUnknownErrorCode { + return true + } + } + + return false }