diff --git a/cmd/api-errors.go b/cmd/api-errors.go index 674b0a1fa3c9b..c2fae9a39ebac 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -944,13 +944,13 @@ var errorCodes = errorCodeMap{ HTTPStatusCode: http.StatusBadRequest, }, ErrPastObjectLockRetainDate: { - Code: "InvalidRequest", - Description: "the retain until date must be in the future", + Code: "InvalidArgument", + Description: "The retain until date must be in the future", HTTPStatusCode: http.StatusBadRequest, }, ErrUnknownWORMModeDirective: { - Code: "InvalidRequest", - Description: "unknown wormMode directive", + Code: "InvalidArgument", + Description: "Unknown wormMode directive", HTTPStatusCode: http.StatusBadRequest, }, ErrObjectLockInvalidHeaders: { diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 87657863b5da8..349cd954d0fa5 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -3134,9 +3134,7 @@ func (api ObjectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r objRetention, err := objectlock.ParseObjectRetention(r.Body) if err != nil { - apiErr := errorCodes.ToAPIErr(ErrMalformedXML) - apiErr.Description = err.Error() - WriteErrorResponse(ctx, w, apiErr, r.URL, guessIsBrowserReq(r)) + WriteErrorResponse(ctx, w, ToAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) return } diff --git a/pkg/bucket/object/lock/lock.go b/pkg/bucket/object/lock/lock.go index 2ed40d7135508..68c8617ef7d14 100644 --- a/pkg/bucket/object/lock/lock.go +++ b/pkg/bucket/object/lock/lock.go @@ -346,7 +346,7 @@ func ParseObjectRetention(reader io.Reader) (*ObjectRetention, error) { return nil, err } if ret.Mode != "" && !ret.Mode.Valid() { - return &ret, ErrUnknownWORMModeDirective + return &ret, ErrMalformedXML } if ret.Mode.Valid() && ret.RetainUntilDate.IsZero() {