fix(s3): match AWS wording for NoSuchBucket and NoSuchUpload messages (#8655)

Several S3 error messages differed from the text AWS sends. NoSuchBucket and an unversioned bucket's BucketNotEmpty drop their trailing period, and every NoSuchBucket in S3Service now comes from one helper. A bucket with a versioning state adds "You must delete all versions in the bucket." to BucketNotEmpty, NoSuchUpload explains that the upload ID may be invalid or the upload aborted or completed, and InvalidPrefix reads "The annotation prefix you have provided is invalid." Error codes and HTTP statuses are unchanged.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-17 18:42:56 -04:00
1 parent f76de9c463
commit a9cb14b2ea
2 files changed
+136 -120

No files matched your search

@@ -23,6 +23,55 @@ class S3BucketErrorResponseIntegrationTest {
.body(containsString("<BucketName>" + bucket + "</BucketName>"));
}
@Test
void noSuchBucketAndNoSuchUploadCarryAwsMessages() {
String bucket = "error-message-bucket";
given().when().get("/" + bucket).then().statusCode(404)
.body(containsString("<Code>NoSuchBucket</Code>"))
.body(containsString("<Message>The specified bucket does not exist</Message>"));
given().when().put("/" + bucket).then().statusCode(200);
given().when().delete("/" + bucket + "/key?uploadId=missing").then().statusCode(404)
.body(containsString("<Code>NoSuchUpload</Code>"))
.body(containsString("<Message>The specified upload does not exist. The upload ID may be invalid, "
+ "or the upload may have been aborted or completed.</Message>"));
given().when().delete("/" + bucket).then().statusCode(204);
}
@Test
void bucketNotEmptyMessageDependsOnVersioningState() {
String plain = "error-message-not-empty";
given().when().put("/" + plain).then().statusCode(200);
given().body("data").when().put("/" + plain + "/key").then().statusCode(200);
given().when().delete("/" + plain).then().statusCode(409)
.body(containsString("<Code>BucketNotEmpty</Code>"))
.body(containsString("<Message>The bucket you tried to delete is not empty</Message>"));
given().when().delete("/" + plain + "/key").then().statusCode(204);
given().when().delete("/" + plain).then().statusCode(204);
String versioned = "error-message-not-empty-versioned";
given().when().put("/" + versioned).then().statusCode(200);
given().contentType("application/xml")
.body("<VersioningConfiguration><Status>Enabled</Status></VersioningConfiguration>")
.when().put("/" + versioned + "?versioning").then().statusCode(200);
given().when().delete("/" + versioned + "/never-written").then().statusCode(204);
given().when().delete("/" + versioned).then().statusCode(409)
.body(containsString("<Code>BucketNotEmpty</Code>"))
.body(containsString("<Message>The bucket you tried to delete is not empty. "
+ "You must delete all versions in the bucket.</Message>"));
}
@Test
void invalidAnnotationPrefixMessage() {
String bucket = "error-message-annotation-prefix";
given().when().put("/" + bucket).then().statusCode(200);
given().body("data").when().put("/" + bucket + "/key").then().statusCode(200);
given().when().get("/" + bucket + "/key?annotation&annotation-prefix=bad%20prefix")
.then().statusCode(400).body(containsString("<Code>InvalidPrefix</Code>"))
.body(containsString("<Message>The annotation prefix you have provided is invalid.</Message>"));
}
@Test
void bucketConfigurationErrorsIncludeBucketName() {
String bucket = "error-response-config-bucket";