Better error when handling a descriptor of size zero

Signed-off-by: Phil Estes <estesp@amazon.com>
This commit is contained in:
Phil Estes 2021-03-10 12:48:14 -05:00
parent 92009ad7a3
commit f6a9942733
No known key found for this signature in database
GPG Key ID: FE2598126B196A38

View File

@ -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)