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
{{ message }}
Repository navigation
Query and Mutate surface raw HTTP errors instead of *HTTPError #293
GraphQL calls through GraphQLClient.Query/Mutate turn non-2xx HTTP responses into a raw, unstructured error:
non-200 OK status code: 401 Unauthorized body: "{\"message\":\"Bad credentials\",...}"
This is visible to users as, e.g., gh pr status / gh gist list / gh release list failing with that raw string when the token is invalid (see cli/cli#8434). The caller cannot parse the status code, headers, or body, because the underlying GraphQL client (cli/shurcooL-graphql) formats the whole response into a plain fmt.Errorf string.
The Do/DoWithContext methods handle this properly via HandleHTTPError (returning *HTTPError); only the named QueryNamed/MutateNamed path leaks the raw error.
Proposed approach
Wrap the inner GraphQL HTTP client's transport so that responses outside the 2xx range become an *HTTPError (existing HandleHTTPError), so the underlying GraphQL client never formats the raw response.
In QueryWithContext/MutateWithContext, unwrap the *url.Error that net/http adds around round-trip failures and return the bare *HTTPError, consistent with the Do path.
After the change, an unauthenticated gh pr status shows:
Activity