fix: preserve per-occurrence layer identity in mutate.Image.Layers() by iahsanGill · Pull Request #2299 · google/go-containerregistry (original) (raw)
When a base image and an appended layer share a diff ID but have different blob digests (e.g. same uncompressed tar, different compression), mutate.Image.Layers() previously returned the appended layer twice instead of [base, appended]. The manifest still listed both digests correctly, but downstream code that walks Layers() to upload blobs would upload the appended layer twice and never push the base's blob, so the PUT manifest would fail with MANIFEST_BLOB_UNKNOWN.
Root cause: Layers() walked the rootfs diff IDs and resolved each via LayerByDiffID, which can't disambiguate two layers with the same diff ID — the addendum overwrites the base entry in diffIDMap.
The manifest layer descriptors are already unambiguous (one entry per occurrence, each with its own digest), so walk those instead and resolve via LayerByDigest. Same length and order, but per-occurrence identity is preserved.
Fixes google#2034
Subserial pushed a commit to Subserial/go-containerregistry that referenced this pull request
When a base image and an appended layer share a diff ID but have different blob digests (e.g. same uncompressed tar, different compression), mutate.Image.Layers() previously returned the appended layer twice instead of [base, appended]. The manifest still listed both digests correctly, but downstream code that walks Layers() to upload blobs would upload the appended layer twice and never push the base's blob, so the PUT manifest would fail with MANIFEST_BLOB_UNKNOWN.
Root cause: Layers() walked the rootfs diff IDs and resolved each via LayerByDiffID, which can't disambiguate two layers with the same diff ID — the addendum overwrites the base entry in diffIDMap.
The manifest layer descriptors are already unambiguous (one entry per occurrence, each with its own digest), so walk those instead and resolve via LayerByDigest. Same length and order, but per-occurrence identity is preserved.
Fixes google#2034
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})