Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This is related to #135, I was also seeing strange behavior with the search API and I think I understand the cause now.
Most of the GitHub api endpoints either return a single result as a single json object (e.g.
GET /user
) or multiple results as a json array (e.g.GET /orgs/:org/members
). However, there are a few endpoints where the endpoint returns a single json object that then contains the paginated array (e.g.GET /repos/:owner/:repo/actions/runs
andGET /search/repositories
) - the problem arises for these latter cases.This pull request has a proposed fix to deal with the merging of these types separately so that we get the "right" behavior for all three cases. The bug is a bit insidious because any results past the first page are concatenated to the result object, but because the attributes are overwritten the new values don't have a
names
attribute and the first results are present with the expected structure. See the example below:Additionally, I think some rethinking of the pagination may be necessary. For example
length(res) < .limit
ingh/R/gh.R
Line 177 in b524a44
next
link). The name of the results array also changes between endpoints so it is difficult to workout what the current # of results is.Another related problem is using a small
.limit
with one of the single result endpoints, e.g.as this currently ends up incorrectly subsetting the results object values instead of the "results".