403: rate limit exceeded
andrewcassidy opened this issue · comments
We periodically get this error when trying to open a PR
Unable to retrieve default branch: 403: rate limit exceeded
{'message': "API rate limit exceeded for 104.45.204.50. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", 'documentation_url': 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'}
We're using version 1.0.19 and I don't see any updates that could relate to this in the codebase
Are you providing your GitHub token in the environment? Can you point me to / show me your workflow file?
@vsoch here's my workflow file which looks exactly like your example as far as I can tell
name: xxxxxxxx
on:
push:
branches-ignore:
- staging
- launchpad
- production
jobs:
auto-pull-request:
name: PullRequestAction
runs-on: ubuntu-latest
steps:
- name: pull-request-action
uses: vsoch/pull-request-action@58a078aed9040e56a85935a37e2544a1b0046e51
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: "xxxxxxxxxx"
PULL_REQUEST_BRANCH: "master"
Is that digest the most recent? I'm not sure why that might happen - we retrieve the token here:
pull-request-action/pull-request.py
Lines 285 to 292 in c8e84ce
pull-request-action/pull-request.py
Line 111 in c8e84ce
1.0.23
and also make sure that your repo settings under actions have the "actions can open PRs" checkbox checked.@vsoch it was working before and still works like 95% of the time, but we notice the error 2 times in the last week. I just upgraded to 1.0.23 to see if that helps. I'll check with the repo admin to see that that box is checked.
Do you do a lot with your org and the GitHub API? The token I would suspect would apply to the global ratelimit for your user or org. That might explain, but it's hard to know. To me, it doesn't look like this is a problem with the action, but rather the message being reported is correct that you (somehow) went over your limit. I think the question is if that message would appear even with the presence of a token (this I am not sure about) I've only see it when I forget to export, and I usually don't get anywhere near the limit!
Let me know if you have any other ideas, I'm afraid I don't at the moment.
@vsoch thanks for your help
I ran into this as well.
I get the sense that github has introduced more rate limiting measures in the last couple of months.
It seems like you could potentially avoid 1 call here in the case where the environment variable is already set:
pull-request-action/pull-request.py
Line 360 in c8e84ce
Good call - do you want to open a PR to tweak this? We could just do:
pull_request_branch = os.environ.get("PULL_REQUEST_BRANCH")
if not pull_request_branch:
pull_request_branch = find_default_branch()
Looks good to me. Perhaps shorter:
pull_request_branch = os.environ.get("PULL_REQUEST_BRANCH") or find_default_branch()
I actually tested that and it still called my function, so I think we want the first one!
okay please see #94 !
Ok please use https://github.com/vsoch/pull-request-action/releases/tag/1.0.24 and let me know if there are other ways you see that we can reduce the API usage.
Folks - I'm still getting some rate limit hits - I'm testing adding retry (on this branch) #96 if anyone is interested in also testing!