Skip to content
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

bugfix: don't use req.Marshal to encode a binary payload… #110

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

manicminer
Copy link
Collaborator

@manicminer manicminer commented Mar 20, 2024

… since this incorrectly assumes source type (which is actually a byteslice) from content-type

related: hashicorp/terraform-provider-azurerm#25333

…ncorrectly assumes source type (which is actually a byteslice) from content-type
… incorrectly assumes the destination type (which is a byteslice) from the content-type
Copy link
Owner

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment because resp.Body can be nil - but otherwise LGTM 👍

result.HttpResponse = resp.Response

err = resp.Unmarshal(result.Contents)
respBody, err := io.ReadAll(resp.Body)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's possible for resp.Body to be nil here fwiw, so this is a potential crash-point:

Suggested change
respBody, err := io.ReadAll(resp.Body)
var respBody io.Reader
if resp.Body != nil {
respBody, err = io.ReadAll(resp.Body)

}
resp.Body.Close()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resp.Body.Close()
respBody.Close()
}

@manicminer manicminer merged commit 6dd97af into main Mar 22, 2024
1 check passed
@manicminer manicminer deleted the bugfix/encoding-storage-blob-from-content branch March 22, 2024 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants