Merge pull request #5154 from estesp/zero-len

Better error when handling a descriptor of size zero
This commit is contained in:
Maksym Pavlenko 2021-03-14 15:40:39 -07:00 committed by GitHub
commit e231b955dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,6 +115,12 @@ func fetch(ctx context.Context, ingester content.Ingester, fetcher Fetcher, desc
return err 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 ws.Offset == desc.Size {
// If writer is already complete, commit and return // If writer is already complete, commit and return
err := cw.Commit(ctx, desc.Size, desc.Digest) err := cw.Commit(ctx, desc.Size, desc.Digest)