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

@@ -864,6 +864,14 @@ public class LambdaWebService implements Resettable {
LOG.debugv("Web function code object s3://{0}/{1} is not readable: {2}", build.bucket, build.key,
e.getMessage());
String object = "s3://" + build.bucket + "/" + build.key;
if (s3Service.isDeleteMarker(build.bucket, build.key, build.versionId)) {
if (build.versionId != null) {
// AWS fails internally on a version that is a delete marker.
throw new LambdaWebInternalServerException();
}
throw new AwsException("ValidationException", "The latest version of the S3 object is a delete marker."
+ " Upload a new object version or pass an explicit S3ObjectVersion.", 400);
}
if (build.versionId == null) {
throw new AwsException("ValidationException", "The specified S3 object does not exist: " + object
+ ". Verify the object exists in the bucket.", 400);
@@ -2132,6 +2132,14 @@ public class S3Service implements Resettable, ResourceProvider {
}
}
/** Whether the version {@code versionId} names, the current one when it is null, is a delete marker. */
public boolean isDeleteMarker(String bucketName, String key, String versionId) {
return resolveBucketEntry(bucketName)
.flatMap(bucket -> findStoredObject(bucket, bucketName, key, versionId))
.map(S3Object::isDeleteMarker)
.orElse(false);
}
public InputStream openObjectStream(String bucketName, String key, String versionId) {
if ("null".equals(versionId)) {
return openObject(bucketName, key, versionId).body();