Fix AttributeError when response body is StreamingBody in error response handling#3683
Closed
armorbreak001 wants to merge 1 commit intoboto:developfrom
Closed
Fix AttributeError when response body is StreamingBody in error response handling#3683armorbreak001 wants to merge 1 commit intoboto:developfrom
armorbreak001 wants to merge 1 commit intoboto:developfrom
Conversation
…ic_error_response When a streaming body wrapper (StreamingChecksumBody or StreamingBody) is used as the response body, calling .strip() directly raises AttributeError because these objects don't have a strip method. Read the body content first if it's a file-like object before calling strip().
Author
|
Duplicate of #3680 (already open, fixes same issue). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4754
When an S3-compatible service (e.g., Wasabi) returns a 5xx error, the error handling path in
_is_generic_error_responsecalls.strip()on the response body. When checksum validation is enabled (default since 1.36.0), the response body is wrapped in aStreamingChecksumBody(orStreamingBody) object, which does not have a.strip()method. This causes anAttributeErrorthat masks the original server error.Changes
Read the body content via
.read()if it is a file-like object before calling.strip(). This handles bothStreamingChecksumBody,StreamingBody, and regular bytes/string bodies without affecting existing behavior for non-streaming responses.Testing