PyGithub / PyGithub/PyGithub

RateLimitExceededException not raised when rate limit exceeds via making many PRs

Open
#2,422 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
1.9k
Avg merge
17m
Merged PRs (30d)
2

Description

When the rate limit is exceeded using by making too many PRs, the RateLimitExceededException is not raised, instead it is a GithubException. I would expect that it would be the rate limit exception, given it's a 403 and gives the rate limit exceeded exception:

403 {"documentation_url": "https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits", "message": "You have exceeded a secondary rate limit. Please wait a few minutes before you try again."}

Example code:

def create_branch(repo, branch_name):
    sb = repo.get_branch(repo.default_branch)
    repo.create_git_ref(ref='refs/heads/' + branch_name, sha=sb.commit.sha)

def exceed():
    for i in range(100):
        repo = g.get_repo("mhoeger/test")
        branch = f"mhoeger/test-branch-{time.time()}"
        create_branch(repo, branch)
        repo.create_file("test.txt", "TEST!", "hi", branch)
        repo.create_pull("testing", "test", repo.default_branch, branch)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the secondary-rate-limit response with the example that creates branches, files, and pull requests repeatedly. Trace how the GitHub API client handles this 403 response and compare it with RateLimitExceededException handling. Done means the documented secondary-rate-limit response raises RateLimitExceededException rather than GithubException, with tests covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.