-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
I've built a tool to gather all stats of all repos in a given org and rank the users, and, as I just found, some times github returns an empty hash on the endpoint that returns the statistics (client.Repositories.ListContributorsStats on go-github).
I changed github.go to debug the issue:
@@ -415,9 +408,13 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
if w, ok := v.(io.Writer); ok {
io.Copy(w, resp.Body)
} else {
- err = json.NewDecoder(resp.Body).Decode(v)
+ content, _ := ioutil.ReadAll(response.Body)
+ body2 := ioutil.NopCloser(bytes.NewReader(content))
+ err = json.NewDecoder(body2).Decode(v)
if err == io.EOF {
err = nil // ignore EOF errors caused by empty response body
+ } else if err != nil {
+ println("Invalid JSON?", string(content))
}
}
}And, it turns out, github returned an empty hash ({}) on a repo that wasn't changed the last year...
Is there anything doable on the go-github side?
FYI: I'm reporting this issue to the GitHub support.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels