diff --git a/cmd/client-s3.go b/cmd/client-s3.go index c9748ccf..bd0cdf94 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -2197,6 +2197,9 @@ func (c *S3Client) PutObjectRetention(ctx context.Context, versionID string, mod // GetObjectRetention - Get object retention for a given object. func (c *S3Client) GetObjectRetention(ctx context.Context, versionID string) (minio.RetentionMode, time.Time, *probe.Error) { bucket, object := c.url2BucketAndObject() + if object == "" { + return "", time.Time{}, probe.NewError(ObjectNameEmpty{}).Trace(c.GetURL().String()) + } modePtr, untilPtr, e := c.api.GetObjectRetention(ctx, bucket, object, versionID) if e != nil { return "", time.Time{}, probe.NewError(e).Trace(c.GetURL().String()) diff --git a/cmd/retention-info.go b/cmd/retention-info.go index 10e0f479..2062a47b 100644 --- a/cmd/retention-info.go +++ b/cmd/retention-info.go @@ -87,7 +87,7 @@ EXAMPLES: $ {{.HelpName}} myminio/mybucket/prefix --recursive --versions 5. Show default lock retention configuration for a bucket - $ {{.HelpName}} --default myminio/mybucket/ + $ {{.HelpName}} myminio/mybucket/ --default `} func parseInfoRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions, defaultMode bool) { @@ -273,9 +273,11 @@ func infoRetentionSingle(ctx context.Context, alias, url, versionID string, list if err != nil { errResp := minio.ToErrorResponse(err.ToGoError()) if errResp.Code != "NoSuchObjectLockConfiguration" { - msg.SetErr(err.ToGoError()) - msg.SetStatus("failure") - printMsg(msg) + if _, ok := err.ToGoError().(ObjectNameEmpty); !ok { + msg.SetErr(err.ToGoError()) + msg.SetStatus("failure") + printMsg(msg) + } return err } err = nil @@ -307,6 +309,10 @@ func getRetention(ctx context.Context, target, versionID string, timeRef time.Ti if versionID != "" || !isRecursive && !withOlderVersions { err := infoRetentionSingle(ctx, alias, urlStr, versionID, false) if err != nil { + if _, ok := err.ToGoError().(ObjectNameEmpty); ok { + console.Infoln("no object name specified, showing bucket default retention mode instead") + return showBucketLock(target) + } return exitStatus(globalErrorExitStatus) } return nil