Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL errors, and especially rate limit errors, are not documented #22607

Closed
1 task done
FiloSottile opened this issue Dec 10, 2022 · 8 comments
Closed
1 task done
Labels
content This issue or pull request belongs to the Docs Content team graphql Content related to GraphQL help wanted Anyone is welcome to open a pull request to fix this issue pumpkin-spice Specifically tracked Hacktoberfest issue - internal purposes stale There is no recent activity on this issue or pull request

Comments

@FiloSottile
Copy link
Contributor

FiloSottile commented Dec 10, 2022

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/graphql

What part(s) of the article would you like to see updated?

There seems to be no documentation for what the GraphQL API returns on error conditions.

In particular, I can't find what error code to expect once the rate limit is exceeded. I see I can use the rateLimit query field to get information on how many points I have left when a query succeeds, but I can't rely on that alone as I might have a few points left and then make a very large request.

I assume a rate limit error will also provide a resetAt field, but I have no idea under what name or path. The only way I can see to develop an app that will handle rate limits gracefully is to burn 5000 points and hit the error to learn how it looks like.

Additional information

No response


Maintainer update

Proposed changes to fix this issue

Expand the Resource limitations article with examples of what happens if you exceed rate limits using the information from the comments below, in particular:

@FiloSottile FiloSottile added the content This issue or pull request belongs to the Docs Content team label Dec 10, 2022
@welcome
Copy link

welcome bot commented Dec 10, 2022

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Dec 10, 2022
@cmwilson21
Copy link
Contributor

@FiloSottile Thanks so much for opening an issue! I'll triage this for the team to take a look 👀

@cmwilson21 cmwilson21 added waiting for review Issue/PR is waiting for a writer's review graphql Content related to GraphQL and removed triage Do not begin working on this issue until triaged by the team labels Dec 12, 2022
@skedwards88
Copy link
Contributor

skedwards88 commented Dec 14, 2022

The response code will be 200, and the errors field will indicate that you have a rate error. For example:

With GitHub CLI, a rate limited response looks like:

% gh api graphql -f query='{
  viewer {
    login
    isSiteAdmin
  }
}'
{
  "errors": [
    {
      "type": "RATE_LIMITED",
      "message": "API rate limit exceeded for user ID 9961."
    }
  ]
}
gh: API rate limit exceeded for user ID 9961.

With curl, a rate limited response looks like:

curl -w "%{http_code}" https://api.github.com/graphql \
  -H "Authorization: token $GITHUB_TOKEN" \
  --compressed \
  --data-binary '{"query":"{\n\t__schema{\n queryType {\n fields{\n name\n }\n }\n }\n}"}'
{"errors":[{"type":"RATE_LIMITED","message":"API rate limit exceeded for user ID 9961."}]}
200

You or anyone else is welcome to add this info to the docs.

@skedwards88 skedwards88 added the help wanted Anyone is welcome to open a pull request to fix this issue label Dec 14, 2022
@FiloSottile
Copy link
Contributor Author

FiloSottile commented Dec 14, 2022 via email

@mmrobins
Copy link

mmrobins commented Dec 14, 2022

yes, there's an x-ratelimit-reset, along with some other useful headers

% curl -vvv https://api.github.com/graphql \
  -H "Authorization: token $GITHUB_TOKEN" \
  --compressed \
  --data-binary '{"query":"{\n\t__schema{\n queryType {\n fields{\n name\n }\n }\n }\n}"}' \
  2> >(grep x-ratelimit)
< x-ratelimit-limit: 5000
< x-ratelimit-remaining: 0
< x-ratelimit-reset: 1670985544
< x-ratelimit-used: 5000
< x-ratelimit-resource: graphql

@cmwilson21 cmwilson21 removed the waiting for review Issue/PR is waiting for a writer's review label Dec 14, 2022
@china170

This comment was marked as spam.

@pgcd
Copy link

pgcd commented Mar 31, 2023

I'm trying to use this query to fetch a single file from my repo:

{
  repository(owner: "myorg", name: "myrepo") {
    content: object(expression: "develop:src/locale_files/de/LC_MESSAGES/django.po") {
      ... on Blob {
        text
      }
    }
  }
}

And the resulting text is truncated at 510292 - there's a flag in the result that confirms that the contents are truncated, but it would've been nice to know that in advance, instead of spending time getting this to work only to find it's completely useless.

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Aug 2, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
@cmwilson21 cmwilson21 removed the stale There is no recent activity on this issue or pull request label Aug 10, 2023
@cmwilson21 cmwilson21 reopened this Aug 10, 2023
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Aug 10, 2023
@cmwilson21 cmwilson21 removed the triage Do not begin working on this issue until triaged by the team label Aug 10, 2023
@felicitymay
Copy link
Contributor

@pgcd - you might find this article useful when you're doing future work using the GraphQL API: Resource limitations - GitHub Docs.

@felicitymay felicitymay added the pumpkin-spice Specifically tracked Hacktoberfest issue - internal purposes label Sep 19, 2023
@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Nov 20, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team graphql Content related to GraphQL help wanted Anyone is welcome to open a pull request to fix this issue pumpkin-spice Specifically tracked Hacktoberfest issue - internal purposes stale There is no recent activity on this issue or pull request
Projects
None yet
Development

No branches or pull requests

8 participants
@mmrobins @FiloSottile @felicitymay @pgcd @skedwards88 @cmwilson21 @china170 and others