Request GET from API returns an empty JSON array

I’ve been having a problem in getting all contributor commit activity statistics from the GitHub REST API. In a workflow, I run this following script:

run: |
          curl --request GET \
          --url${{ github.repository }}/stats/contributors \
          --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
          --header 'content-type: application/json' > contribute.json

No run errors here, but when I write this to a JSON file, it only contains an empty JSON array:



Does anyone know the problem of why it is outputting an empty JSON file? This is a private repository if it helps with finding the problem. Thanks in advance!

:wave: @kkarp9: an empty JSON array is returned if there are no contributors beyond the initial committer. Here’s an example public repository showcasing this behavior:

Does this help explain what you’re seeing? :thought_balloon:

Thank you for reaching out on this. Yes, I do have contributors. I verified it on my repos. An update to this issue is that for some reason when I run the workflow to request GitHub API from other branches that I have, it returns the JSON array of all contributors. Only in the master branch I get the empty JSON array. Any intake on this?

francisfuzz We’re seeing this as well with the contributors API! We have GH Enterprise Cloud and internal repos.

It seems that if the API sits for a while it will return an empty response and a 202, but if you immediately hit it again you’ll get a 200 with the expected response data. I have recreated this issue over the course of a few days now.{ORG}/{REPO}/stats/contributors

  • When the status returns a 202 Accepted the response is empty.
  • When the status returns a 200 Ok the response is complete