[Bug]: `KeyError: 'tag_name'` because of GitHub API's rate limit
debemdeboas opened this issue · comments
Describe the bug
If you run the script in quick succession, you'll get rate-limited by GitHub's API when checking the script's version (utils/version.py#10
).
This is the traceback:
Traceback (most recent call last):
File "/home/debem/personal/storieslettuce/RedditVideoMakerBot/main.py", line 44, in <module>
checkversion(__VERSION__)
File "/home/debem/personal/storieslettuce/RedditVideoMakerBot/utils/version.py", line 10, in checkversion
latestversion = response.json()["tag_name"]
KeyError: 'tag_name'
There are a few ways to fix this issue. One of them is to verify the API response and check if code 403 is returned (GitHub's rate limit) and ignore it, like so:
def checkversion(__VERSION__: str):
response = requests.get(
"https://api.github.com/repos/elebumm/RedditVideoMakerBot/releases/latest"
)
if response.status_code == 403: # Rate limit
print(f"Skipping script version check because we exceeded GitHub's rate limit. Using version ({__VERSION__}).")
return
latestversion = response.json()["tag_name"]
Reproduction Steps
Run the script 10 times in quick succession
Expected behavior
Nothing goes wrong
Screenshots
No response
System Information
Operating System : Ubuntu 22.04.3 LTS
Python version : Python 3.10.13
App version / Branch : master
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
Additional Context
No response
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.
Issue closed due to being stale. Please reopen if issue persists in latest version.