From f6a99427337756c2592d15fee91087ede04ec6b8 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Wed, 10 Mar 2021 12:48:14 -0500 Subject: [PATCH] Better error when handling a descriptor of size zero Signed-off-by: Phil Estes --- remotes/handlers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/remotes/handlers.go b/remotes/handlers.go index 671fea106..9c864ec72 100644 --- a/remotes/handlers.go +++ b/remotes/handlers.go @@ -115,6 +115,12 @@ func fetch(ctx context.Context, ingester content.Ingester, fetcher Fetcher, desc return err } + if desc.Size == 0 { + // most likely a poorly configured registry/web front end which responded with no + // Content-Length header; unable (not to mention useless) to commit a 0-length entry + // into the content store. Error out here otherwise the error sent back is confusing + return errors.Wrapf(errdefs.ErrInvalidArgument, "unable to fetch descriptor (%s) which reports content size of zero", desc.Digest) + } if ws.Offset == desc.Size { // If writer is already complete, commit and return err := cw.Commit(ctx, desc.Size, desc.Digest)