fix: return NoSuchVersion error for non-existent versionId

When requesting an object with a versionId that doesn't exist, S3
returns NoSuchVersion, not NoSuchKey. Updated getObject to distinguish
between a missing key and a missing version.

Fixes https://github.com/hectorvent/floci/issues/33
This commit is contained in:
Byron Ludwig committed 2026-03-24 14:50:08 +00:00
1 parent 38f7c5c2eb
commit 5576222999
2 files changed
+14 -1

No files matched your search

@@ -248,7 +248,9 @@ public class S3Service {
}
S3Object obj = objectStore.get(storeKey)
.orElseThrow(() -> new AwsException("NoSuchKey", "The specified key does not exist.", 404));
.orElseThrow(() -> versionId != null
? new AwsException("NoSuchVersion", "The specified version does not exist.", 404)
: new AwsException("NoSuchKey", "The specified key does not exist.", 404));
if (obj.isDeleteMarker()) {
throw new AwsException("NoSuchKey", "The specified key does not exist.", 404);