fix(s3): return ObjectLockConfigurationNotFoundError for non-lock buckets (#971)

GetObjectLockConfiguration was returning a 200 with ObjectLockEnabled=Enabled
for every bucket regardless of whether object lock was enabled at creation time.

Real AWS returns ObjectLockConfigurationNotFoundError (HTTP 404) when the bucket
was not created with x-amz-bucket-object-lock-enabled: true.

Added an isObjectLockEnabled() guard in S3Service before returning the retention
configuration. The controller's existing try-catch routes the AwsException to
the XML error response with no additional changes needed.

Fixes #960
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-05-20 23:43:56 -05:00
1 parent b200280a83
commit 4edb6f93f6
2 files changed
+141

No files matched your search

@@ -949,6 +949,10 @@ public class S3Service {
Bucket bucket = bucketStore.get(bucketName)
.orElseThrow(() -> new AwsException("NoSuchBucket",
"The specified bucket does not exist.", 404));
if (!bucket.isObjectLockEnabled()) {
throw new AwsException("ObjectLockConfigurationNotFoundError",
"Object Lock configuration does not exist for this bucket", 404);
}
return bucket.getDefaultRetention();
}