fix(s3): return every bucket when ListBuckets has no max-buckets (#7886)

Paging ListBuckets capped a request without max-buckets at 10000 buckets with
a continuation token, so a caller that reads only the first response, like
the Floci UI, lost every bucket after that. Without max-buckets, return the
whole list on one page again.
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-11-10 08:26:24 -04:00
1 parent 6565225234
commit 14c3004240
3 files changed
+18 -2

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@
configured default region. Bare requests omit the field. Buckets are listed in name order and
paged by `max-buckets` (1 to 10000), with a `ContinuationToken` on every page but the last; a
`max-buckets` out of range or a token that is unreadable or was issued to another account is
refused with `InvalidArgument`. Filtering by `prefix` and `bucket-region` is not implemented;
refused with `InvalidArgument`. Without `max-buckets`, every bucket comes back on one page. Filtering by `prefix` and `bucket-region` is not implemented;
those parameters do not limit the returned bucket list.
## Event Notifications
@@ -630,7 +630,7 @@ public class S3Service implements Resettable, ResourceProvider {
"max-buckets must be between 1 and " + MAX_LIST_BUCKETS + ".", 400);
}
return Pagination.paginate(listBuckets(), Bucket::getName,
maxBuckets == null ? MAX_LIST_BUCKETS : maxBuckets, continuationToken,
maxBuckets == null ? Integer.MAX_VALUE : maxBuckets, continuationToken,
"buckets:" + ownerId(),
token -> new AwsException("InvalidArgument", "The continuation token provided is incorrect.", 400));
}
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.PaginatedResult;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.HybridStorage;
import io.floci.aws.core.storage.InMemoryStorage;
@@ -319,6 +320,21 @@ class S3ServiceTest {
assertEquals("InvalidBucketName", ex.getErrorCode());
}
@Test
void listBucketsWithoutPaginationParametersReturnsMoreThanTenThousandBucketsOnOnePage() {
InMemoryStorage<String, Bucket> bucketStore = new InMemoryStorage<>();
S3Service service = new S3Service(bucketStore, new InMemoryStorage<>(), tempDir.resolve("many-s3"), false);
for (int i = 0; i <= 10000; i++) {
String name = "bucket-" + i;
bucketStore.put(name, new Bucket(name));
}
PaginatedResult<Bucket> page = service.listBuckets(null, null);
assertEquals(10001, page.items().size());
assertNull(page.nextToken());
}
@Test
void objectPathsRefuseABucketNameThatEscapesTheAccountDirectory() {
InMemoryStorage<String, Bucket> bucketStore = new InMemoryStorage<>();