fix(lambda-web): answer a delete marker as the code object as AWS does (#7079)

* fix(lambda-web): answer a delete marker as the code object as AWS does

A delete marker as the latest version is refused with AWS's own
message, and a versionId that names a delete marker is an internal
error, as on AWS.

* test(lambda-web): cover the null delete marker of a suspended bucket
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-31 17:53:41 -04:00
1 parent fbd07bd6f5
commit 02b9669066
5 files changed
+51 -1

No files matched your search

@@ -88,6 +88,15 @@ class LambdaWebCodeBucketIntegrationTest {
refused(null, VERSIONING);
}
@Test
void theNullDeleteMarkerOfASuspendedBucketIsRefusedBeforeTheBucketPolicy() {
s3Service.putBucketVersioning(bucket, "Suspended");
put(bucket);
s3Service.deleteObject(bucket, "app.zip");
refused(null, "The latest version of the S3 object is a delete marker. Upload a new object version or pass"
+ " an explicit S3ObjectVersion.");
}
@Test
void lambdaNeedsGetObjectVersionUnderTheConditionsItSends() {
s3Service.putBucketVersioning(bucket, "Enabled");
@@ -455,6 +455,31 @@ class LambdaWebIntegrationTest {
.body("message", equalTo("The specified S3 object does not exist: s3://" + BUCKET
+ "/missing.zip. Verify the object exists in the bucket."));
s3Service.putObject(BUCKET, "deleted.zip", LambdaWebZips.indexJs(""), "application/zip", Map.of());
String marker = s3Service.deleteObject(BUCKET, "deleted.zip").getVersionId();
given().contentType("application/json")
.body("""
{"buildConfig": {"codeConfig": {"s3Object": {"bucket": "%s", "key": "deleted.zip"}},
"runtimeConfig": {"runtime": "nodejs24.x"}},
"serviceConfig": {"executionRoleArn": "%s"}}
""".formatted(BUCKET, ROLE))
.when().post(revisions)
.then().statusCode(400)
.header("X-Amzn-Errortype", "ValidationException")
.body("message", equalTo("The latest version of the S3 object is a delete marker. Upload a new object"
+ " version or pass an explicit S3ObjectVersion."));
given().contentType("application/json")
.body("""
{"buildConfig": {"codeConfig": {"s3Object": {"bucket": "%s", "key": "deleted.zip",
"versionId": "%s"}},
"runtimeConfig": {"runtime": "nodejs24.x"}},
"serviceConfig": {"executionRoleArn": "%s"}}
""".formatted(BUCKET, marker, ROLE))
.when().post(revisions)
.then().statusCode(500)
.header("X-Amzn-Errortype", "InternalServerException")
.body(equalTo("{}"));
given().contentType("application/json")
.body("""
{"buildConfig": %s, "serviceConfig": {"executionRoleArn": "%s",