From aaf4fb11841f1062741342f7f7a016fd12dd41a0 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Mon, 2 Sep 2024 13:36:43 +0100 Subject: [PATCH] batch: repl: A missing prefix in the remote source will fail replication (#20365) When the prefix field is not provided in the remote source of a yaml replication job, the code fails to do listing and makes replication successful. This commit fixes it. --- cmd/batch-handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/batch-handlers.go b/cmd/batch-handlers.go index bcb78f2b3..15e70a532 100644 --- a/cmd/batch-handlers.go +++ b/cmd/batch-handlers.go @@ -388,7 +388,11 @@ func (r *BatchJobReplicateV1) StartFromSource(ctx context.Context, api ObjectLay objInfoCh := make(chan miniogo.ObjectInfo, 1) go func() { - for _, prefix := range r.Source.Prefix.F() { + prefixes := r.Source.Prefix.F() + if len(prefixes) == 0 { + prefixes = []string{""} + } + for _, prefix := range prefixes { prefixObjInfoCh := c.ListObjects(ctx, r.Source.Bucket, miniogo.ListObjectsOptions{ Prefix: strings.TrimSpace(prefix), WithVersions: minioSrc,