-
Notifications
You must be signed in to change notification settings - Fork 838
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
Panic when checking res.StatusCode #2175
Comments
One of the principles for these APIs is that if the API receives an HTTP response then it will be propagated to the caller (barring bugs of course). For your example using an invalid proxy, the response field is nil because there was no response; while personally I feel this is more descriptive than populating a zero-initialized HTTP response I can see that having it could make error checking a bit easier. |
This will be resolved in vNext following the same pattern we introduced in azblob; responses will be returned by reference e.g. |
Closing as the HTTP status code response helpers should simplify this case. |
When doing a GET to a resource group using the ARM v17 API, I received a panic when checking the response StatusCode. Since one must check the err and the http status code to tell if there has been a 404, I would never expect dereferencing the response would cause a panic.
You can reliably cause a panic if you set the
HTTP_PROXY
env variable to an address that fails in tcp dial as demonstrated below if you added the following code to check the response.There should be clear direction on how to handle a tcp dial error and/or a default value populated into the response struct.
The text was updated successfully, but these errors were encountered: