Skip to content

Commit e0a32c0

Browse files
committed
Ensure our pre-flight HEAD request is always by-tag if we're pushing a tag
This is a latent bug the system has had for large manifests that we now have for all manifests instead! 😄 (This also would artificially inflate our speedups since all the pre-flight HEAD requests would be by-digest which are infinitely cacheable and thus very, very fast.)
1 parent cab9251 commit e0a32c0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

registry/push.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ func EnsureManifest(ctx context.Context, ref Reference, manifest json.RawMessage
4545

4646
// try HEAD request before pushing
4747
// if it matches, then we can assume child objects exist as well
48-
r, err := Lookup(ctx, ref, &LookupOptions{Head: true})
48+
headRef := ref
49+
if headRef.Tag != "" {
50+
// if this function is called with *both* tag *and* digest, the code below works correctly and pushes by tag and then validates by digest, but this lookup specifically will prefer the digest instead and skip when it shouldn't
51+
headRef.Digest = ""
52+
}
53+
r, err := Lookup(ctx, headRef, &LookupOptions{Head: true})
4954
if err != nil {
5055
return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err)
5156
}

0 commit comments

Comments
 (0)