From b4eeeb844958bc9bcaa35d8ab99de21f01ae7518 Mon Sep 17 00:00:00 2001 From: ebozduman Date: Wed, 14 Apr 2021 00:01:53 -0700 Subject: [PATCH] PutObjectRetention : return matching error XML as AWS S3 (#11973) --- cmd/object-handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 1251ff03d..e72131ca1 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -3587,6 +3587,11 @@ func (api objectAPIHandlers) GetObjectRetentionHandler(w http.ResponseWriter, r getObjectInfo = api.CacheAPI().GetObjectInfo } + if rcfg, _ := globalBucketObjectLockSys.Get(bucket); !rcfg.LockEnabled { + writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidBucketObjectLockConfiguration), r.URL, guessIsBrowserReq(r)) + return + } + opts, err := getOpts(ctx, r, bucket, object) if err != nil { writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) @@ -3600,7 +3605,6 @@ func (api objectAPIHandlers) GetObjectRetentionHandler(w http.ResponseWriter, r } retention := objectlock.GetObjectRetentionMeta(objInfo.UserDefined) - if !retention.Mode.Valid() { writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNoSuchObjectLockConfiguration), r.URL, guessIsBrowserReq(r)) return