botocore icon indicating copy to clipboard operation
botocore copied to clipboard

GetBucketPolicy broken by PR #3276

Open odormond opened this issue 4 months ago • 5 comments

Describe the bug

Trying to get a bucket policy consistently fails with fake error 500 Internal Server Error.

The issue comes from PR #3276 forcibly trying to parse the body as an XML document and failing as it's a JSON document and then considering it _looks_like_special_case_error due to this line: https://github.com/boto/botocore/blob/bab77d87db47c28dfa4329c9b849c5febf3998cc/botocore/handlers.py#L180

Regression Issue

  • [X] Select this option if this issue appears to be a regression.

Expected Behavior

The bucket policy document is returned successfully.

Current Behavior

An error is ClientError is raised.

Reproduction Steps

With adequate permissions, and a bucket with some policy configured, run:

aws --debug s3api get-bucket-policy --bucket test-bucket-with-policy

Possible Solution

Don't feed a response body whose header says Content-Type: application/json to an XML parser.

Additional Information/Context

No response

SDK version used

1.35.45

Environment details (OS name and version, etc.)

Ubuntu 22.04.5 LTS

odormond avatar Oct 23 '24 08:10 odormond