mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
2 files changed
+14
-1
No files matched your search
@@ -155,6 +155,17 @@ class S3VersioningServiceTest {
|
||||
assertTrue(versions.stream().anyMatch(S3Object::isDeleteMarker));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getObjectWithNonExistentVersionIdThrowsNoSuchVersion() {
|
||||
s3Service.putBucketVersioning("versioned-bucket", "Enabled");
|
||||
s3Service.putObject("versioned-bucket", "test.txt",
|
||||
"data".getBytes(StandardCharsets.UTF_8), "text/plain", null);
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () ->
|
||||
s3Service.getObject("versioned-bucket", "test.txt", "fake-version-id"));
|
||||
assertEquals("NoSuchVersion", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listObjectsExcludesDeleteMarkers() {
|
||||
s3Service.putBucketVersioning("versioned-bucket", "Enabled");
|
||||
|
||||
Reference in new issue
Block a user