1
votes

I've got the following error when retrieving the version of an object stored in my S3 running on Localstack (docker) :

com.amazonaws.services.s3.model.AmazonS3Exception: Internal Server Error (Service: Amazon S3; Status Code: 500; Error Code: 500 Internal Server Error; Request ID: null), S3 Extended Request ID: null

I've tested with versions 1.11.163, 1.11.359, 1.11.383 of aws-java-sdk.

Listing and deleting the files works but I can't get the version using the SDK.

The thing is that when using the cli I can list the objects' versions in my bucket.

When listing the versions of the files in my bucket :

aws --endpoint-url=http://localhost:4572 s3api list-object-versions --bucket my-bucket --prefix testFolder

I get the following output :

{
"Versions": [
    {
        "LastModified": "2018-08-10T08:52:06.193Z", 
        "VersionId": "0", 
        "ETag": "\"da9a0adf68f7fa4da720e10914283cc9\"", 
        "StorageClass": "STANDARD", 
        "Key": "testFolder/test.txt", 
        "Owner": {
            "DisplayName": "webfile", 
            "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
        }, 
        "IsLatest": true, 
        "Size": 7366
    }, 
    {
        "LastModified": "2018-08-10T08:52:06.188Z", 
        "VersionId": "0", 
        "ETag": "\"5f22390dd70444e4f3ea347313442a6d\"", 
        "StorageClass": "STANDARD", 
        "Key": "testFolder/0001/test.txt", 
        "Owner": {
            "DisplayName": "webfile", 
            "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
        }, 
        "IsLatest": true, 
        "Size": 2507
    }, 
    {
        "LastModified": "2018-08-10T08:52:06.191Z", 
        "VersionId": "0", 
        "ETag": "\"9001b739dd280ace7b6b7ae45377484a\"", 
        "StorageClass": "STANDARD", 
        "Key": "testFolder/0001/test-other.txt", 
        "Owner": {
            "DisplayName": "webfile", 
            "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
        }, 
        "IsLatest": true, 
        "Size": 4589
    }, 
    {
        "LastModified": "2018-08-10T08:52:06.185Z", 
        "VersionId": "0", 
        "ETag": "\"4d32ffe9a1f7e272c78aa80e95fb9cf3\"", 
        "StorageClass": "STANDARD", 
        "Key": "testFolder/test-other.txt", 
        "Owner": {
            "DisplayName": "webfile", 
            "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a"
        }, 
        "IsLatest": true, 
        "Size": 15549
    }
]
}

Here is how I create my S3Configuration :

private static S3Configuration s3Configuration() {
    S3Configuration s3Configuration = new S3Configuration();
    s3Configuration.setBucket("my-bucket");
    return s3Configuration;
}

Here is how I create my AmazonS3 client :

private static AmazonS3 amazonS3() {
    final AWSCredentials credentials = new BasicAWSCredentials("foobar","foobar");
    final EndpointConfiguration endpointConfiguration = new EndpointConfiguration("http://localhost:4572",DEFAULT_REGION.getName());

    AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(credentials))
            .withEndpointConfiguration(endpointConfiguration)
            .withPathStyleAccessEnabled(true);

    return amazonS3ClientBuilder.build();
}

The exception occurs whenever I try to list the versions of the files in my bucket using :

VersionListing versionListing = amazonS3.listVersions(new ListVersionsRequest().withBucketName(bucketName));

Or trying to get the version for a specific file :

VersionListing versionListing = amazonS3.listVersions(bucketName, objectKey);

Where objectKey is retrieve from an S3ObjectSummary.getKey()

Any idea of what I am missing?

Thanks for your help.

1

1 Answers

0
votes

Seems like a bug

This should fix your problem

new ListVersionsRequest()
                        .withEncodingType("")
                        .withBucketName(bucketName)
                        .withPrefix(key);