diff --git a/cmd/auth-handler.go b/cmd/auth-handler.go index 01d9918cc..688b40edc 100644 --- a/cmd/auth-handler.go +++ b/cmd/auth-handler.go @@ -151,9 +151,6 @@ func validateAdminSignature(ctx context.Context, r *http.Request, region string) s3Err = isReqAuthenticated(ctx, r, region, serviceS3) } if s3Err != ErrNone { - reqInfo := (&logger.ReqInfo{}).AppendTags("requestHeaders", dumpRequest(r)) - ctx := logger.SetReqInfo(ctx, reqInfo) - logger.LogIf(ctx, errors.New(getAPIError(s3Err).Description), logger.Application) return cred, nil, owner, s3Err } diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 1280d1e17..dde08993f 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -431,7 +431,6 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, // Unmarshal list of keys to be deleted. deleteObjectsReq := &DeleteObjectsRequest{} if err := xmlDecoder(r.Body, deleteObjectsReq, maxBodySize); err != nil { - logger.LogIf(ctx, err, logger.Application) writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) return } @@ -511,11 +510,10 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, } if object.VersionID != "" && object.VersionID != nullVersionID { if _, err := uuid.Parse(object.VersionID); err != nil { - logger.LogIf(ctx, fmt.Errorf("invalid version-id specified %w", err)) apiErr := errorCodes.ToAPIErr(ErrNoSuchVersion) deleteResults[index].errInfo = DeleteError{ Code: apiErr.Code, - Message: apiErr.Description, + Message: fmt.Sprintf("%s (%s)", apiErr.Description, err), Key: object.ObjectName, VersionID: object.VersionID, } @@ -924,16 +922,18 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h // be loaded in memory, the remaining being put in temporary files. reader, err := r.MultipartReader() if err != nil { - logger.LogIf(ctx, err) - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL) + apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest) + apiErr.Description = fmt.Sprintf("%s (%s)", apiErr.Description, err) + writeErrorResponse(ctx, w, apiErr, r.URL) return } // Read multipart data and save in memory and in the disk if needed form, err := reader.ReadForm(maxFormMemory) if err != nil { - logger.LogIf(ctx, err, logger.Application) - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL) + apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest) + apiErr.Description = fmt.Sprintf("%s (%s)", apiErr.Description, err) + writeErrorResponse(ctx, w, apiErr, r.URL) return } @@ -943,8 +943,9 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h // Extract all form fields fileBody, fileName, fileSize, formValues, err := extractPostPolicyFormValues(ctx, form) if err != nil { - logger.LogIf(ctx, err, logger.Application) - writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL) + apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest) + apiErr.Description = fmt.Sprintf("%s (%s)", apiErr.Description, err) + writeErrorResponse(ctx, w, apiErr, r.URL) return } diff --git a/cmd/metrics-v2.go b/cmd/metrics-v2.go index 0e4aed039..8a9562cc5 100644 --- a/cmd/metrics-v2.go +++ b/cmd/metrics-v2.go @@ -2416,7 +2416,8 @@ func metricsServerHandler() http.Handler { enc := expfmt.NewEncoder(w, contentType) for _, mf := range mfs { if err := enc.Encode(mf); err != nil { - logger.LogIf(r.Context(), err) + // client may disconnect for any reasons + // we do not have to log this. return } } diff --git a/cmd/metrics.go b/cmd/metrics.go index a35defffb..d39fafae7 100644 --- a/cmd/metrics.go +++ b/cmd/metrics.go @@ -590,7 +590,8 @@ func metricsHandler() http.Handler { enc := expfmt.NewEncoder(w, contentType) for _, mf := range mfs { if err := enc.Encode(mf); err != nil { - logger.LogIf(r.Context(), err) + // client may disconnect for any reasons + // we do not have to log this. return } } diff --git a/cmd/object-api-options.go b/cmd/object-api-options.go index 649c123ef..c5881109b 100644 --- a/cmd/object-api-options.go +++ b/cmd/object-api-options.go @@ -96,9 +96,7 @@ func getOpts(ctx context.Context, r *http.Request, bucket, object string) (Objec vid := strings.TrimSpace(r.Form.Get(xhttp.VersionID)) if vid != "" && vid != nullVersionID { - _, err := uuid.Parse(vid) - if err != nil { - logger.LogIf(ctx, err) + if _, err := uuid.Parse(vid); err != nil { return opts, InvalidVersionID{ Bucket: bucket, Object: object, diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 15f93b06a..74f34342f 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -397,7 +397,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj // Handle only errInvalidRange. Ignore other // parse error and treat it as regular Get // request like Amazon S3. - if rangeErr == errInvalidRange { + if errors.Is(rangeErr, errInvalidRange) { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidRange), r.URL) return } @@ -433,7 +433,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj proxyGetErr := ErrorRespToObjectError(perr, bucket, object) if !isErrObjectNotFound(proxyGetErr) && !isErrVersionNotFound(proxyGetErr) && !isErrPreconditionFailed(proxyGetErr) && !isErrInvalidRange(proxyGetErr) { - logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr)) + logger.LogIf(ctx, fmt.Errorf("Proxying request (replication) failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr)) } } if reader != nil && proxy.Proxy && perr == nil { @@ -803,12 +803,12 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob // Handle only errInvalidRange. Ignore other // parse error and treat it as regular Get // request like Amazon S3. - if err == errInvalidRange { + if errors.Is(err, errInvalidRange) { writeErrorResponseHeadersOnly(w, errorCodes.ToAPIErr(ErrInvalidRange)) return } - logger.LogIf(ctx, err) + logger.LogIf(ctx, err, logger.Application) } }