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
► gh --version
gh version 2.14.3 (2022-07-26)
https://github.com/cli/cli/releases/tag/v2.14.3
I'm trying to use GraphQL API to fetch repositories with a certain file, including its content. The file is not expected to be present in every repository, I'm only interested in those where it exists. GraphQL API returns partial results (replacing the file field with null) in such cases and a list of errors with the reason. As I understand from this article: https://hasura.io/blog/graphql-nulls-cheatsheet/#nulls-in-the-response it's normal and shouldn't be considered a failed request. So I expect gh to keep querying subsequent pages and accumulate results and errors. Instead, it fetches the first page and stops, as if the query has failed.
I redacted results for brevity. Notice "hasNextPage": true.
You can see that the response data contains some results with the file's contents and some results with "file": null. And every null case is explained in the errors array. These errors are not fatal and shouldn't fail the query.
Expected vs actual behavior
Expected: get all pages with partial results from each query accumulated in the .data.organization.repositories.nodes array and all errors accumulated in the .errors array.
Thanks for the detailed report! Absolutely agreed that GraphQL errors are not always fatal and that in this case pagination should continue even if there were some partial GraphQL errors. This is perhaps indicative of gh api possibly being over-zealous with error handling and that we should possibly add an opt out mechanism so that the consumer itself can decide how to handle errors, particularly those from GraphQL. But, as a stopgap fix, we could just disable GraphQL error processing in --paginate mode and return all server results verbatim.
mislav
added
p2
Affects more than a few users but doesn't prevent core functions
and removed
needs-triage
needs to be reviewed
labels
Aug 10, 2022
Describe the bug
I'm trying to use GraphQL API to fetch repositories with a certain file, including its content. The file is not expected to be present in every repository, I'm only interested in those where it exists. GraphQL API returns partial results (replacing the file field with
null
) in such cases and a list of errors with the reason. As I understand from this article: https://hasura.io/blog/graphql-nulls-cheatsheet/#nulls-in-the-response it's normal and shouldn't be considered a failed request. So I expectgh
to keep querying subsequent pages and accumulate results and errors. Instead, it fetches the first page and stops, as if the query has failed.Steps to reproduce the behavior
An example query:
Result:
I redacted results for brevity. Notice
"hasNextPage": true
.You can see that the response
data
contains some results with the file's contents and some results with"file": null
. And everynull
case is explained in theerrors
array. These errors are not fatal and shouldn't fail the query.Expected vs actual behavior
.data.organization.repositories.nodes
array and all errors accumulated in the.errors
array.gh
stops after the first pageRelevant links
Potentially related issues
gh api
#5652api
command #1115The text was updated successfully, but these errors were encountered: