From 2d12e04693b046a5319cbe4b43eac6fdbe06f0a1 Mon Sep 17 00:00:00 2001 From: Jona Brown Date: Mon, 2 Feb 2026 19:27:27 +0100 Subject: [PATCH] fix 499 status to 503 when errors appear in console --- cmd/api-errors.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/api-errors.go b/cmd/api-errors.go index 6ccd5fab2..656262933 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -452,6 +452,7 @@ const ( ErrIAMNotInitialized apiErrCodeEnd // This is used only for the testing code + ErrServerShutdown ) type errorCodeMap map[APIErrorCode]APIError @@ -2144,6 +2145,11 @@ var errorCodes = errorCodeMap{ Description: "Invalid UTF-8 character detected.", HTTPStatusCode: http.StatusBadRequest, }, + ErrServerShutdown: { + Code: "ServiceUnavailable", + Description: "Server is shutting down, please retry", + HTTPStatusCode: http.StatusServiceUnavailable, + }, } // toAPIErrorCode - Converts embedded errors. Convenience @@ -2253,7 +2259,13 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) { case errKMSDefaultKeyAlreadyConfigured: apiErr = ErrKMSDefaultKeyAlreadyConfigured case context.Canceled: - apiErr = ErrClientDisconnected + // Check if this is due to server shutdown (global context cancelled) + // vs client disconnecting + if GlobalContext.Err() != nil { + apiErr = ErrServerShutdown + } else { + apiErr = ErrClientDisconnected + } case context.DeadlineExceeded: apiErr = ErrRequestTimedout case objectlock.ErrInvalidRetentionDate: