Skip to content

bug: Deleting versions while listing them is broken since 3.0.0 #12255

@philipp94831

Description

@philipp94831

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

We need to delete many object versions in S3. We use this snippet to delete all versions of objects for a given prefix

        final S3Client s3Client = ...;
        final String bucketName = ...;
        final String prefix = ...;
        final ListObjectVersionsRequest request = ListObjectVersionsRequest.builder()
                .bucket(bucketName)
                .prefix(prefix)
                .build();
        final ListObjectVersionsIterable versionListing = s3Client.listObjectVersionsPaginator(request);
        versionListing.stream()
                .map(response -> response.versions().stream()
                        .map(s3Object -> ObjectIdentifier.builder()
                                .key(s3Object.key())
                                .versionId(s3Object.versionId())
                                .build())
                        .collect(Collectors.toList()))
                .forEach(keys -> {
                    if (!keys.isEmpty()) {
                        s3Client.deleteObjects(DeleteObjectsRequest.builder()
                                .bucket(bucketName)
                                .delete(builder -> builder
                                        .objects(keys))
                                .build());
                    }
                });

If there are more than 999 versions, which is the maximum page size for listing versions, the second ListObjectVersionsResponse is empty, although it should not be. Therefore, the remaining versions are not deleted. This is broken since localstack 3.0.0 but works in 2.3.2. We are using AWS SDK 2.29.52.

Expected Behavior

Object versions are properly retrieved while deleting them.

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

Testcontainers Java

Environment

- OS: Ubuntu and Windows
- LocalStack:
  LocalStack version: 3.0.0
  LocalStack Docker image sha:
  LocalStack build date:
  LocalStack build git hash:

Anything else?

No response

Metadata

Metadata

Assignees

Labels

aws:s3Amazon Simple Storage Servicestatus: resolved/fixedResolved with a fix or an implementationtype: bugBug report

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions