0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00

fix(ui): fix image details view (#2470)

when a UI client tries to view image details
for an image with multiple tags pointing to the same digest
we make a query to dynamodb having duplicate keys (same digest)
resulting in an error and the client is redirect back to image
overview.

closes: #2464

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
peusebiu 2024-06-14 19:22:48 +03:00 committed by GitHub
parent 56f41dcc15
commit e023936e8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -1439,7 +1439,11 @@ func expandedRepoInfo(ctx context.Context, repo string, metaDB mTypes.MetaDB, cv
continue 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) imageMetaMap, err := metaDB.FilterImageMeta(ctx, tagsDigests)

View file

@ -236,6 +236,16 @@ func TestWrapperErrors(t *testing.T) {
}) })
}) })
Convey("FilterImageMeta", func() { 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() { Convey("manifest meta unmarshal error", func() {
err = setImageMeta(image.Digest(), badProtoBlob, dynamoWrapper) //nolint: contextcheck err = setImageMeta(image.Digest(), badProtoBlob, dynamoWrapper) //nolint: contextcheck
So(err, ShouldBeNil) So(err, ShouldBeNil)
@ -243,6 +253,7 @@ func TestWrapperErrors(t *testing.T) {
_, err = dynamoWrapper.FilterImageMeta(ctx, []string{image.DigestStr()}) _, err = dynamoWrapper.FilterImageMeta(ctx, []string{image.DigestStr()})
So(err, ShouldNotBeNil) So(err, ShouldNotBeNil)
}) })
Convey("MediaType ImageIndex, getProtoImageMeta fails", func() { Convey("MediaType ImageIndex, getProtoImageMeta fails", func() {
err := dynamoWrapper.SetImageMeta(multiarchImageMeta.Digest, multiarchImageMeta) //nolint: contextcheck err := dynamoWrapper.SetImageMeta(multiarchImageMeta.Digest, multiarchImageMeta) //nolint: contextcheck
So(err, ShouldBeNil) So(err, ShouldBeNil)