stargazercount is 0 unless fetched directly
Describe the bug Using latest 1.128:
ghContent.getOwner().getStarGazersCount() returns 0, but
gitHub.getRepository(ghContent.getOwner().getFullName()).getStargazersCount()); returns the proper count.
Probably related to #349 and #1068
Expected behavior stargazer count should be fetched, throw error or return -1 or similar - anything but returning 0.
Is the GHContent object created above, a result of a code search API call? https://docs.github.com/en/rest/reference/search#search-code.
If so, then the root cause is clear as the GitHub Rest API doesn't provide the field stargazers_count in the response.
{
"total_count": 7,
...
"items": [
{
"name": "classes.js",
...
"repository": {
"id": 167174,
...
"stargazers_url": "https://api.github.com/repos/jquery/jquery/stargazers",
...
}
}
]
}
whereas the direct query for a repository provides the stargazers_count field as well as the stargazers_url - https://docs.github.com/en/rest/reference/repos#get-a-repository
[
{
"id": 1296269,
...
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
...
"stargazers_count": 80,
...
}
]
yes, ghcontent is fetched from search query.
We should replace int with Integer and check for null. Or we could have the stargazers_count default to -1 in GHRepository and test for that before returning it.
This another example of some endpoints (search endpoints especially) returning incomplete data, which #1138 would help us to address.