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