Closed
Description
Describe the bug
When calling S3Client#getObject(GetObjectRequest)
there is different behavior for the error thrown depending on whether a version is provided or not.
For example, on a versioned bucket
- Providing only a
key
and noversionId
results inNoSuchKeyException: The specified key does not exist
. - Providing both a
key
and aversionId
results inS3Exception: The specified version does not exist.
I'm guessing that the version is considered a subresource of the key, but it seems strange that we get a message about the version not existing when the key doesn't exist either.
Expected Behavior
A NoSuchKeyException
is thrown whenever the specified key does not exist, regardless whether a version is provided or not.
Current Behavior
- Providing only a
key
and noversionId
results inNoSuchKeyException: The specified key does not exist
. - Providing both a
key
and aversionId
results inS3Exception: The specified version does not exist.
Steps to Reproduce
- Create a versioned bucket.
- Invoke
S3Client#getObject(GetObjectRequest)
using an invalid key and any versionId. - Note exception returned is
S3Exception
instead ofNoSuchKeyException
.
Context
I would like accurately tell my consumer that the key is invalid. Telling them the version does not exist is "true" but missing the context that the key
is actually missing.
Your Environment
-
AWS Java SDK version used:
2.15.63
-
JDK version used:
openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
-
Operating System and version: OSX 10.15.7