boto3.client("s3").head_bucket does not throw NoSuchBucket as per documentation
See original GitHub issueContrary to documentation, boto3.client(“s3”).head_bucket(Bucket=bucket_name) does not throw S3.Client.exceptions.NoSuchBucket. It throws An error occurred (404) when calling the HeadBucket operation: Not Found https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.head_bucket
import boto3
client = boto3.client("s3")
try:
client.head_bucket(Bucket='bucket-does-not-exist')
except client.exceptions.NoSuchBucket:
print('exception caught')
The above code snippet should print ‘exception caught’. However, It throws the below exception.
File "/Users/ashaik/.local/share/virtualenvs/loadenv38-el3BARCC/lib/python3.8/site-packages/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Users/ashaik/.local/share/virtualenvs/loadenv38-el3BARCC/lib/python3.8/site-packages/botocore/client.py", line 635, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (404) when calling the HeadBucket operation: Not Found
Please align documentation and behavior of exception thrown.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
S3 — Boto3 Docs 1.26.32 documentation - Amazon AWS
Parameters. Bucket (string) --. [REQUIRED]. The bucket name to which the upload was taking place. When using this action with an access point, ......
Read more >Boto3 client upload_fileobj throws error NoSuchBucket
First thing to check is the region. If you installed the CLI, you probably have the credentials and the config in your home...
Read more >s3 - Amazon Web Services - Go SDK - AWS Documentation
See the Amazon Simple Storage Service client S3 for more information on creating ... Code: NoSuchBucket Description: The specified bucket does not exist....
Read more >Boto3 – Amazon S3 As Python Object Store
It can throw an “NoSuchKey” exception, if the key is not present. import boto3 import pickle #Connect to S3 s3 = boto3.client('s3') #Read...
Read more >Handling Errors in Boto3 & Botocore - Trek10
It's a well-documented fact that saying "hah, no need to worry about X failing" is ... import boto3 import botocore.exceptions s3 = boto3.client('s3')...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @stobrien89 ok thanks for looking into this again though!
Hi again @BastianZim,
Had a chance to look into this further this morning and it looks like the documentation has been updated:
From what I understand, they won’t be able to remove the error from the model, as it would be a breaking change, so it will remain listed under the exceptions section, which is derived from the s3 model. Wish there was more we could do here!