[#186] Fix errors

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2021-11-26 12:19:06 +03:00 committed by Alex Vanin
parent 6ee48fb549
commit 8127d68128
2 changed files with 7 additions and 0 deletions

View file

@ -380,6 +380,10 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.
errors.GetAPIError(errors.ErrMalformedXML), additional...) errors.GetAPIError(errors.ErrMalformedXML), additional...)
return return
} }
if len(reqBody.Parts) == 0 {
h.logAndSendError(w, "invalid xml with parts", reqInfo, errors.GetAPIError(errors.ErrMalformedXML), additional...)
return
}
initPart, err := h.obj.GetUploadInitInfo(r.Context(), uploadInfo) initPart, err := h.obj.GetUploadInitInfo(r.Context(), uploadInfo)
if err != nil { if err != nil {

View file

@ -186,6 +186,9 @@ func (n *layer) CompleteMultipartUpload(ctx context.Context, p *CompleteMultipar
if len(objects) == 1 { if len(objects) == 1 {
obj, err := n.headLastVersionIfNotDeleted(ctx, p.Info.Bkt, p.Info.Key) obj, err := n.headLastVersionIfNotDeleted(ctx, p.Info.Bkt, p.Info.Key)
if err != nil { if err != nil {
if errors.IsS3Error(err, errors.ErrNoSuchKey) {
return nil, errors.GetAPIError(errors.ErrInvalidPart)
}
return nil, err return nil, err
} }
if obj != nil && obj.Headers[UploadIDAttributeName] != "" { if obj != nil && obj.Headers[UploadIDAttributeName] != "" {