diff --git a/api/handler/multipart_upload.go b/api/handler/multipart_upload.go index 8a68fd9a..c9ba0cbc 100644 --- a/api/handler/multipart_upload.go +++ b/api/handler/multipart_upload.go @@ -104,10 +104,7 @@ func (h *handler) CreateMultipartUploadHandler(w http.ResponseWriter, r *http.Re } uploadID := uuid.New() - additional := []zap.Field{ - zap.String("uploadID", uploadID.String()), - zap.String("Key", reqInfo.ObjectName), - } + additional := []zap.Field{zap.String("uploadID", uploadID.String())} p := &layer.CreateMultipartParams{ Info: &layer.UploadInfoParams{ @@ -121,11 +118,11 @@ func (h *handler) CreateMultipartUploadHandler(w http.ResponseWriter, r *http.Re if containsACLHeaders(r) { key, err := h.bearerTokenIssuerKey(r.Context()) if err != nil { - h.logAndSendError(w, "couldn't get gate key", reqInfo, err) + h.logAndSendError(w, "couldn't get gate key", reqInfo, err, additional...) return } if _, err = parseACLHeaders(r.Header, key); err != nil { - h.logAndSendError(w, "could not parse acl", reqInfo, err) + h.logAndSendError(w, "could not parse acl", reqInfo, err, additional...) return } p.Data.ACLHeaders = formACLHeadersForMultipart(r.Header) @@ -141,7 +138,7 @@ func (h *handler) CreateMultipartUploadHandler(w http.ResponseWriter, r *http.Re p.Info.Encryption, err = formEncryptionParams(r) if err != nil { - h.logAndSendError(w, "invalid sse headers", reqInfo, err) + h.logAndSendError(w, "invalid sse headers", reqInfo, err, additional...) return } @@ -152,7 +149,7 @@ func (h *handler) CreateMultipartUploadHandler(w http.ResponseWriter, r *http.Re p.CopiesNumbers, err = h.pickCopiesNumbers(p.Header, bktInfo.LocationConstraint) if err != nil { - h.logAndSendError(w, "invalid copies number", reqInfo, err) + h.logAndSendError(w, "invalid copies number", reqInfo, err, additional...) return } @@ -208,18 +205,19 @@ func (h *handler) UploadPartHandler(w http.ResponseWriter, r *http.Request) { var ( queryValues = r.URL.Query() uploadID = queryValues.Get(uploadIDHeaderName) - additional = []zap.Field{zap.String("uploadID", uploadID), zap.String("Key", reqInfo.ObjectName)} + partNumStr = queryValues.Get(partNumberHeaderName) + additional = []zap.Field{zap.String("uploadID", uploadID), zap.String("partNumber", partNumStr)} ) - partNumber, err := strconv.Atoi(queryValues.Get(partNumberHeaderName)) + partNumber, err := strconv.Atoi(partNumStr) if err != nil || partNumber < layer.UploadMinPartNumber || partNumber > layer.UploadMaxPartNumber { - h.logAndSendError(w, "invalid part number", reqInfo, errors.GetAPIError(errors.ErrInvalidPartNumber)) + h.logAndSendError(w, "invalid part number", reqInfo, errors.GetAPIError(errors.ErrInvalidPartNumber), additional...) return } body, err := h.getBodyReader(r) if err != nil { - h.logAndSendError(w, "failed to get body reader", reqInfo, err) + h.logAndSendError(w, "failed to get body reader", reqInfo, err, additional...) return } @@ -241,7 +239,7 @@ func (h *handler) UploadPartHandler(w http.ResponseWriter, r *http.Request) { p.Info.Encryption, err = formEncryptionParams(r) if err != nil { - h.logAndSendError(w, "invalid sse headers", reqInfo, err) + h.logAndSendError(w, "invalid sse headers", reqInfo, err, additional...) return } @@ -266,12 +264,13 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { reqInfo = middleware.GetReqInfo(ctx) queryValues = reqInfo.URL.Query() uploadID = queryValues.Get(uploadIDHeaderName) - additional = []zap.Field{zap.String("uploadID", uploadID), zap.String("Key", reqInfo.ObjectName)} + partNumStr = queryValues.Get(partNumberHeaderName) + additional = []zap.Field{zap.String("uploadID", uploadID), zap.String("partNumber", partNumStr)} ) - partNumber, err := strconv.Atoi(queryValues.Get(partNumberHeaderName)) + partNumber, err := strconv.Atoi(partNumStr) if err != nil || partNumber < layer.UploadMinPartNumber || partNumber > layer.UploadMaxPartNumber { - h.logAndSendError(w, "invalid part number", reqInfo, errors.GetAPIError(errors.ErrInvalidPartNumber)) + h.logAndSendError(w, "invalid part number", reqInfo, errors.GetAPIError(errors.ErrInvalidPartNumber), additional...) return } @@ -282,7 +281,7 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { } srcBucket, srcObject, err := path2BucketObject(src) if err != nil { - h.logAndSendError(w, "invalid source copy", reqInfo, err) + h.logAndSendError(w, "invalid source copy", reqInfo, err, additional...) return } @@ -295,13 +294,13 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { srcBktInfo, err := h.getBucketAndCheckOwner(r, srcBucket, api.AmzSourceExpectedBucketOwner) if err != nil { - h.logAndSendError(w, "could not get source bucket info", reqInfo, err) + h.logAndSendError(w, "could not get source bucket info", reqInfo, err, additional...) return } bktInfo, err := h.getBucketAndCheckOwner(r, reqInfo.BucketName) if err != nil { - h.logAndSendError(w, "could not get target bucket info", reqInfo, err) + h.logAndSendError(w, "could not get target bucket info", reqInfo, err, additional...) return } @@ -350,12 +349,12 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { p.Info.Encryption, err = formEncryptionParams(r) if err != nil { - h.logAndSendError(w, "invalid sse headers", reqInfo, err) + h.logAndSendError(w, "invalid sse headers", reqInfo, err, additional...) return } if err = p.Info.Encryption.MatchObjectEncryption(layer.FormEncryptionInfo(srcInfo.Headers)); err != nil { - h.logAndSendError(w, "encryption doesn't match object", reqInfo, errors.GetAPIError(errors.ErrBadRequest), zap.Error(err)) + h.logAndSendError(w, "encryption doesn't match object", reqInfo, fmt.Errorf("%w: %s", errors.GetAPIError(errors.ErrBadRequest), err), additional...) return } @@ -375,7 +374,7 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) { } if err = middleware.EncodeToResponse(w, response); err != nil { - h.logAndSendError(w, "something went wrong", reqInfo, err) + h.logAndSendError(w, "something went wrong", reqInfo, err, additional...) } } @@ -395,7 +394,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. Bkt: bktInfo, Key: reqInfo.ObjectName, } - additional = []zap.Field{zap.String("uploadID", uploadID), zap.String("Key", reqInfo.ObjectName)} + additional = []zap.Field{zap.String("uploadID", uploadID)} ) reqBody := new(CompleteMultipartUpload) @@ -451,7 +450,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. // space XML writer to keep connection with the client. if err = responseWriter(w, response); err != nil { - errLogger(w, "something went wrong", reqInfo, err) + errLogger(w, "something went wrong", reqInfo, err, additional...) } }