boto3
boto3 copied to clipboard
`S3.Client.head_object()` raises `S3.Client.exceptions.ClientError` instead of the documented `S3.Client.exceptions.NoSuchKey`
Describe the bug
When calling S3.Client.head_object()
and the provided key is not found in the S3 bucket, the function does not raise the expected error type.
Expected Behavior
I expected the function to raise S3.Client.exceptions.NoSuchKey
as per the docs, and also consistent with the behavior of S3.Client.get_object()
.
Current Behavior
The function raises S3.Client.exceptions.ClientError
.
Reproduction Steps
session = boto3.Session()
client = session.client("s3")
client.head_object(Bucket="MyBucket", Key="NonExistingKey")
Possible Solution
Raise the expected error type.
Additional Information/Context
No response
SDK version used
boto3==1.28.83 and botocore==1.31.83
Environment details (OS name and version, etc.)
WSL 2 (Ubuntu 20.04)