diff --git a/pkg/extensions/search/resolver.go b/pkg/extensions/search/resolver.go index 638cebb5..349932ae 100644 --- a/pkg/extensions/search/resolver.go +++ b/pkg/extensions/search/resolver.go @@ -1439,7 +1439,11 @@ func expandedRepoInfo(ctx context.Context, repo string, metaDB mTypes.MetaDB, cv continue } - tagsDigests = append(tagsDigests, repoMeta.Tags[i].Digest) + digest := repoMeta.Tags[i].Digest + + if !zcommon.Contains(tagsDigests, digest) { + tagsDigests = append(tagsDigests, digest) + } } imageMetaMap, err := metaDB.FilterImageMeta(ctx, tagsDigests) diff --git a/pkg/meta/dynamodb/dynamodb_test.go b/pkg/meta/dynamodb/dynamodb_test.go index 036cd652..39a60c65 100644 --- a/pkg/meta/dynamodb/dynamodb_test.go +++ b/pkg/meta/dynamodb/dynamodb_test.go @@ -236,6 +236,16 @@ func TestWrapperErrors(t *testing.T) { }) }) Convey("FilterImageMeta", func() { + Convey("FilterImageMeta with duplicate digests", func() { + image := CreateRandomImage() + + err := dynamoWrapper.SetRepoReference(ctx, "repo", "tag", image.AsImageMeta()) + So(err, ShouldBeNil) + + _, err = dynamoWrapper.FilterImageMeta(ctx, []string{image.DigestStr(), image.DigestStr()}) + So(err, ShouldNotBeNil) + }) + Convey("manifest meta unmarshal error", func() { err = setImageMeta(image.Digest(), badProtoBlob, dynamoWrapper) //nolint: contextcheck So(err, ShouldBeNil) @@ -243,6 +253,7 @@ func TestWrapperErrors(t *testing.T) { _, err = dynamoWrapper.FilterImageMeta(ctx, []string{image.DigestStr()}) So(err, ShouldNotBeNil) }) + Convey("MediaType ImageIndex, getProtoImageMeta fails", func() { err := dynamoWrapper.SetImageMeta(multiarchImageMeta.Digest, multiarchImageMeta) //nolint: contextcheck So(err, ShouldBeNil)