Cannot delete item from key retrieved from object summary
When trying to delete all items from a bucket, an exception is thrown for items with '//' in their keys, even though those item summaries are returned by listObjectsV2:
val request = new ListObjectsV2Request();
request.setPrefix(KEY_PREFIX);
request.setBucketName(BUCKET_NAME);
val objectSummaries = this.s3Client.listObjectsV2(request).getObjectSummaries();
List<String> failedKeys = new ArrayList<>();
objectSummaries.forEach(summary -> {
try {
this.s3Client.deleteObject(BUCKET_NAME, summary.getKey());
} catch (Exception ex) {
failedKeys.add(summary.getKey());
}
});
val objectSummariesAfterDeletion = this.s3Client.listObjectsV2(request).getObjectSummaries();
assertTrue(CollectionUtils.isEmpty(objectSummariesAfterDeletion));
In the above example, keys in the list failedKeys all start with "phoenix.scanner.testing/email//test/". Even though summaries for these items are returned by listObjectsV2, the objects themselves cannot be retrieved or deleted using the key. Attempts to do so result in the following exception:
com.amazonaws.services.s3.model.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: Amazon S3; Status Code: 403; Error Code: SignatureDoesNotMatch; Request ID: 834FCBEDDC8434C8; S3 Extended Request ID: rM3EzzZ2NiodtulLVCqxM8I1flyX4KV2/JtqngQgeXF+Dk0LeSx0YZky6El8xJ428EaUUloMqok=), S3 Extended Request ID: rM3EzzZ2NiodtulLVCqxM8I1flyX4KV2/JtqngQgeXF+Dk0LeSx0YZky6El8xJ428EaUUloMqok=
The stack trace includes the following entries:
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1660)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1324)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1074)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:745)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:719)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:701)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:669)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:651)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:515)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4443)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4390)
at com.amazonaws.services.s3.AmazonS3Client.getObject(AmazonS3Client.java:1427)
Items with similar keys that did not include '//' can be retrieved and deleted successfully,.
Hi @etovian, can you check if you are using Apache httpclient-4.5.7 or newer?
Apache made some breaking changes in 4.5.7 and it impacted S3 APIs. Having // in the path is mentioned, we are tracking the issue in #1919 where you can see more details about it.
Using httpclient-4.5.5 should solve the issue.
Debora,
Switching to 4.5.5 did the trick, thanks! Sorry for the dup! (I did look around for an existing issue first, but 1919 got by me.) . Thanks again!