ezyang / ghstack

Submit stacked diffs to GitHub on the command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hitting GitHub API limits

gsathya opened this issue · comments

I just tried to push 15 commits using ghstack and it crashed after uploading 10 with this error:

ERROR: Fatal exception
Traceback (most recent call last):
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/github_real.py", line 159, in rest
    resp.raise_for_status()
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.github.com/repos/facebook/REDACTED/pulls

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/logs.py", line 107, in manager
    yield
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/__main__.py", line 101, in main
    ghstack.submit.main(
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/submit.py", line 203, in main
    submitter.prepare_updates()
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/submit.py", line 932, in prepare_updates
    self.process_new_commit(s)
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/submit.py", line 620, in process_new_commit
    r = self.github.post(
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/github.py", line 53, in post
    return self.rest('post', path, **kwargs)
  File "/Users/gsn/homebrew/lib/python3.10/site-packages/ghstack/github_real.py", line 161, in rest
    raise RuntimeError(pretty_json)
RuntimeError: {
 "message": "You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.",
 "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits"
}

It might be nice if ghstack warned that creating more than 10 PRs would cause trouble with GitHub API limits and exit, rather than creating a subset of PRs and leaving state inconsistent.