From b74b3fa74ec33b022683b0bfe252f2b587529ae9 Mon Sep 17 00:00:00 2001 From: zhumingze Date: Thu, 29 May 2025 11:06:37 +0800 Subject: [PATCH] fix(objectnode): fix incorrect statusCode when creating volume in objectnode. #1000146602 Signed-off-by: zhumingze --- objectnode/api_handler_bucket.go | 5 +++++ objectnode/result_error.go | 1 + 2 files changed, 6 insertions(+) diff --git a/objectnode/api_handler_bucket.go b/objectnode/api_handler_bucket.go index 08eb38534..828f1dd52 100644 --- a/objectnode/api_handler_bucket.go +++ b/objectnode/api_handler_bucket.go @@ -123,6 +123,11 @@ func (o *ObjectNode) createBucketHandler(w http.ResponseWriter, r *http.Request) if err = o.mc.AdminAPI().CreateDefaultVolume(bucket, userInfo.UserID); err != nil { log.LogErrorf("createBucketHandler: create bucket fail: requestID(%v) volume(%v) accessKey(%v) err(%v)", GetRequestID(r), bucket, param.AccessKey(), err) + if err == proto.ErrDuplicateVol { + err = DuplicateVol + } else { + err = InternalErrorCode(err) + } return } diff --git a/objectnode/result_error.go b/objectnode/result_error.go index 66fefe2a3..16fa208f3 100644 --- a/objectnode/result_error.go +++ b/objectnode/result_error.go @@ -90,6 +90,7 @@ var ( ObjectLockConfigurationNotFound = &ErrorCode{"ObjectLockConfigurationNotFoundError", "Object Lock configuration does not exist for this bucket", http.StatusNotFound} TooManyRequests = &ErrorCode{"TooManyRequests", "too many requests, please retry later", http.StatusTooManyRequests} MalformedPOSTRequest = &ErrorCode{ErrorCode: "MalformedPOSTRequest", ErrorMessage: "The body of your POST request is not well-formed multipart/form-data.", StatusCode: http.StatusBadRequest} + DuplicateVol = &ErrorCode{ErrorCode: "DuplicateVol", ErrorMessage: "Duplicate Vol", StatusCode: http.StatusBadRequest} ) type ErrorCode struct {