diff --git a/cmd/erasure-multipart.go b/cmd/erasure-multipart.go index 6c74a6998..95b876556 100644 --- a/cmd/erasure-multipart.go +++ b/cmd/erasure-multipart.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2023 MinIO, Inc. +// Copyright (c) 2015-2025 MinIO, Inc. // // This file is part of MinIO Object Storage stack // @@ -928,7 +928,19 @@ func (er erasureObjects) ListObjectParts(ctx context.Context, bucket, object, up } start := objectPartIndexNums(partNums, partNumberMarker) - if start != -1 { + if partNumberMarker > 0 && start == -1 { + // Marker not present among what is present on the + // server, we return an empty list. + return result, nil + } + + if partNumberMarker > 0 && start != -1 { + if start+1 >= len(partNums) { + // Marker indicates that we are the end + // of the list, so we simply return empty + return result, nil + } + partNums = partNums[start+1:] } diff --git a/cmd/object-api-multipart_test.go b/cmd/object-api-multipart_test.go index 5949eabce..b45cd9179 100644 --- a/cmd/object-api-multipart_test.go +++ b/cmd/object-api-multipart_test.go @@ -1378,6 +1378,24 @@ func testListObjectPartsStale(obj ObjectLayer, instanceType string, disks []stri }, }, }, + // partinfos - 4. + { + Bucket: bucketNames[0], + Object: objectNames[0], + MaxParts: 2, + IsTruncated: false, + UploadID: uploadIDs[0], + PartNumberMarker: 4, + }, + // partinfos - 5. + { + Bucket: bucketNames[0], + Object: objectNames[0], + MaxParts: 2, + IsTruncated: false, + UploadID: uploadIDs[0], + PartNumberMarker: 100, + }, } // Collection of non-exhaustive ListObjectParts test cases, valid errors @@ -1412,10 +1430,14 @@ func testListObjectPartsStale(obj ObjectLayer, instanceType string, disks []stri {bucketNames[0], objectNames[0], uploadIDs[0], 0, 10, partInfos[0], nil, true}, // Test case with maxParts set to less than number of parts (Test number 13). {bucketNames[0], objectNames[0], uploadIDs[0], 0, 3, partInfos[1], nil, true}, - // Test case with partNumberMarker set (Test number 14)-. + // Test case with partNumberMarker set (Test number 14). {bucketNames[0], objectNames[0], uploadIDs[0], 0, 2, partInfos[2], nil, true}, - // Test case with partNumberMarker set (Test number 15)-. + // Test case with partNumberMarker set (Test number 15). {bucketNames[0], objectNames[0], uploadIDs[0], 3, 2, partInfos[3], nil, true}, + // Test case with partNumberMarker set (Test number 16). + {bucketNames[0], objectNames[0], uploadIDs[0], 4, 2, partInfos[4], nil, true}, + // Test case with partNumberMarker set (Test number 17). + {bucketNames[0], objectNames[0], uploadIDs[0], 100, 2, partInfos[5], nil, true}, } for i, testCase := range testCases {