From e060308318e328ef90010802d7b31a1a63943c44 Mon Sep 17 00:00:00 2001 From: Aleksey Kravchenko Date: Wed, 25 Dec 2024 20:46:42 +0300 Subject: [PATCH] [#531] Fix the error codes when checking the ACL format Signed-off-by: Aleksey Kravchenko --- api/errors/errors.go | 7 +++++++ api/handler/put.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/errors/errors.go b/api/errors/errors.go index 7ce7c5fe9..2e033a530 100644 --- a/api/errors/errors.go +++ b/api/errors/errors.go @@ -57,6 +57,7 @@ const ( ErrInvalidCopyDest ErrInvalidPolicyDocument ErrInvalidObjectState + ErrMalformedACL ErrMalformedXML ErrMissingContentLength ErrMissingContentMD5 @@ -456,6 +457,12 @@ var errorCodes = errorCodeMap{ Description: "The requested range is not satisfiable", HTTPStatusCode: http.StatusRequestedRangeNotSatisfiable, }, + ErrMalformedACL: { + ErrCode: ErrMalformedACL, + Code: "MalformedACLError", + Description: "The ACL that you provided was not well formed or did not validate against our published schema.", + HTTPStatusCode: http.StatusBadRequest, + }, ErrMalformedXML: { ErrCode: ErrMalformedXML, Code: "MalformedXML", diff --git a/api/handler/put.go b/api/handler/put.go index 9775de52b..c3776f790 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -744,7 +744,7 @@ func parseCannedACL(header http.Header) (string, error) { return acl, nil } - return "", fmt.Errorf("unknown acl: %s", acl) + return "", apierr.GetAPIErrorWithError(apierr.ErrMalformedACL, fmt.Errorf("unknown acl: %s", acl)) } func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {