-
Notifications
You must be signed in to change notification settings - Fork 282
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
Include response body in 'unexpected status' error message. #29
Comments
Thanks for the issue report @cjwagner, and for providing the details. This issue is already on my radar, as PR #24 was sent to address a similar need. See discussion there for some background and #24 (comment) for latest status. The details you're provided in the issue should help find a viable resolution. I'd prefer to think about this and discuss it in the issue first. Once we have agreement on a resolution plan, implementing the fix will be the easier part. |
Ok, I think adding a
I'm not sure whether to use %s or %q to format the response body. @cjwagner, would you be able to share sample response bodies during those errors, if you have them available? A bigger step might be to create a struct error type with a I've sent PR #30, we can discuss the details there. |
Here is an example: The solution shouldn't be specific to the format or contents of the response body though since this is just an example from GitHub. The |
The response body would be very useful for debugging error messages for unexpected statuses. Many 4xx and 5xx responses include useful explanations in their body text.
In particular the https://github.com/kubernetes/test-infra repo uses the https://github.com/shurcooL/githubv4 library to interact with GitHub's v4 API and we are seeing lots of 502 and 403 errors that should include explanations in the response bodies.
ref: kubernetes/test-infra#7466
The error is generated here:
graphql/graphql.go
Lines 72 to 74 in 3658993
Adding a best effort
ReadAll
of the response body and appending it to the error text would make this error message much more useful.I'd be happy to PR this change if this seems reasonable.
The text was updated successfully, but these errors were encountered: