-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3Client.headObject does not throw NoSuchBucketException/NoSucheKeyException when bucket doesn't exist #1983
Comments
Hi @disordered, the exception shows HTTP status code 301 - Moved Permanently, which is a more specific response case. It's returned when the bucket do exists but in a different region than the region you're using to send the requests. And I think you'll only see this response code when you use S3 path-style requests. When I run the sample code you provided with a bucket that does not exists, using virtual hosted-style, I get:
Do you think that could be the case why you're seeing 301? |
From what I can tell the default configuration disables path-style requests and I don't explicitly enable it.
I guess I accidentally picked a wrong bucket name to test against. |
Did some investigation: I ran the CLI command
Then, CLI automatically updated the host to Bucket names are globally unique, meaning that after a bucket is created the name of that bucket cannot be used by another AWS account in any AWS Region until the bucket is deleted. You are seeing 403 Forbidden in CLI because the Let me know if you have follow up questions. |
Describe the bug
S3Client.headObject(request)
will throwNoSuchKeyException
when key doesn't exist, but will result in the following when the bucket doesn't exist:Expected Behavior
It should either throw
NoSuchKeyException
orNoSuchBucketException
likeS3Client.headBucket(request)
does.Current Behavior
Missing bucket results in generic exception:
Steps to Reproduce
Possible Solution
Context
I'm trying to implement exist checks, so better solution would be to provide
objectExists/bucketExists
.Your Environment
2.13.71
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OSX 10.15.5.
The text was updated successfully, but these errors were encountered: