-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
boto3.client("s3").head_bucket does not throw NoSuchBucket as per documentation #2499
Comments
@ashaik687 - Thank you for your post. The API model provided by S3 that the AWS SDKs use to generate the code and documentation for their S3 clients shows NoSuchBucket as the error shape for a HeadBucket operation. Unfortunately we won't be able to make the requested change in our documentation to account for this. All of the AWS SDKs use the same model provided to us by the S3 team to generate the code and documentation for their S3 clients, unfortunately the way in which the model is written by the S3 team does not allow for removing the constant used for NoSuchBucket from this operation without creating a breaking change. |
There's no way for the S3 model to indicate that a 404 error from HeadBucket should be converted to a NoSuchBucket error? |
@benkehoe - Since HeadBucket operations doesn't return an HTTP response body the SDK can't convert the response to a modeled error so instead it just returns a generic HTTP 404 response. |
@stobrien89 Sorry to be pinging you out of the blue but would it be possible to add a note or something somewhere for this, as I just stumbled over the same thing. Also, can we expect this to never change or might this be something that gets fixed in the future? |
Hi @BastianZim, My apologies for the delayed response. It seems like something could be done from a documentation standpoint since it seems they won't be changing the API behavior (I'll double-check on that), so I'll see if they're able to fix this upstream. |
Thank you @stobrien89! |
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! |
Hi @stobrien89 ok thanks for looking into this again though! |
Method which works:
|
Contrary 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
The above code snippet should print 'exception caught'. However, It throws the below exception.
Please align documentation and behavior of exception thrown.
The text was updated successfully, but these errors were encountered: