return error for AppendObject() API (#21272)

This commit is contained in:
Harshavardhana
2025-05-07 08:37:12 -07:00
committed by GitHub
parent 9ea14c88d8
commit 6d18dba9a2
4 changed files with 33 additions and 2 deletions
+24 -1
View File
@@ -25,6 +25,7 @@ import (
"net/textproto"
"regexp"
"strings"
"sync/atomic"
"github.com/minio/madmin-go/v3"
"github.com/minio/minio/internal/auth"
@@ -427,9 +428,31 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
HTTPStatusCode: http.StatusUpgradeRequired,
}, r.URL)
default:
defer logger.AuditLog(r.Context(), w, r, mustGetClaimsFromToken(r))
defer atomic.AddUint64(&globalHTTPStats.rejectedRequestsInvalid, 1)
// When we are not running in S3 Express mode, generate appropriate error
// for x-amz-write-offset HEADER specified.
if _, ok := r.Header[xhttp.AmzWriteOffsetBytes]; ok {
tc, ok := r.Context().Value(mcontext.ContextTraceKey).(*mcontext.TraceCtxt)
if ok {
tc.FuncName = "s3.AppendObject"
tc.ResponseRecorder.LogErrBody = true
}
writeErrorResponse(r.Context(), w, getAPIError(ErrNotImplemented), r.URL)
return
}
tc, ok := r.Context().Value(mcontext.ContextTraceKey).(*mcontext.TraceCtxt)
if ok {
tc.FuncName = "s3.ValidRequest"
tc.ResponseRecorder.LogErrBody = true
}
writeErrorResponse(r.Context(), w, APIError{
Code: "BadRequest",
Description: fmt.Sprintf("An error occurred when parsing the HTTP request %s at '%s'",
Description: fmt.Sprintf("An unsupported API call for method: %s at '%s'",
r.Method, r.URL.Path),
HTTPStatusCode: http.StatusBadRequest,
}, r.URL)