You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The expression (&azcore.ResponseError{RawResponse: &http.Response{}}).Error() panics. This is because runtime.Payload(&http.Response{}) panics, because it calls the standard library function io.ReadAll on a nil resp.Body and io.ReadAll doesn't nil-check its Reader (golang/go#64714).
For completeness, note that runtime.Payload(nil) also panics because it doesn't nil-check resp, but I think that code path is not reachable via azcore.ResponseError. It'd be nice to fix for other callers of runtime.Payload() though.
This isn't something that we see is causing a production problem (although perhaps there is a minor robustness issue in the highly improbable production case that any of these fields is not set).
But, it's something that trips us up from time to time in a unit test context - when unit testing some other behavior, it's possible to inadvertently instantiate a ResponseError that will then cause a panic when Error() is called.
If only to simplify unit testing, it would be neat if (*azcore.ResponseError) Error() did not panic on &azcore.ResponseError{RawResponse: &http.Response{}}.
The text was updated successfully, but these errors were encountered:
Bug Report
go version
: go version go1.21.4 linux/amd64Similar issue to #21838.
The expression
(&azcore.ResponseError{RawResponse: &http.Response{}}).Error()
panics. This is becauseruntime.Payload(&http.Response{})
panics, because it calls the standard library functionio.ReadAll
on a nilresp.Body
andio.ReadAll
doesn't nil-check its Reader (golang/go#64714).For completeness, note that
runtime.Payload(nil)
also panics because it doesn't nil-check resp, but I think that code path is not reachable viaazcore.ResponseError
. It'd be nice to fix for other callers of runtime.Payload() though.This isn't something that we see is causing a production problem (although perhaps there is a minor robustness issue in the highly improbable production case that any of these fields is not set).
But, it's something that trips us up from time to time in a unit test context - when unit testing some other behavior, it's possible to inadvertently instantiate a ResponseError that will then cause a panic when Error() is called.
If only to simplify unit testing, it would be neat if
(*azcore.ResponseError) Error()
did not panic on&azcore.ResponseError{RawResponse: &http.Response{}}
.The text was updated successfully, but these errors were encountered: