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

Explicitly return Error when GITHUB API rate limit is exceeded #29

Open
tintinthong opened this issue Oct 10, 2022 · 6 comments
Open

Explicitly return Error when GITHUB API rate limit is exceeded #29

tintinthong opened this issue Oct 10, 2022 · 6 comments
Labels
bug Something isn't working hacktoberfest

Comments

@tintinthong
Copy link
Contributor

Rate limit gets hit for unauthenticated request very easily. The error tho is uninformative, for example.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/cli.py", line 181, in main
    get_links()
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/cli.py", line 84, in get_links
    info = unfollow_main()
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 212, in main
    return unfollowed_future.result()
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/opt/homebrew/Cellar/[email protected]/3.10.7/Frameworks/Python.framework/Versions/3.10/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 174, in run_unfollow
    unfollows = get_unfollows(username)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 130, in get_unfollows
    get_followers(username, write_file=True)
  File "/Users/tintinthong/Github/who-unfollowed-me/unfollow/unfollow.py", line 90, in get_followers
    write_followers(user_object["login"])
TypeError: string indices must be integers

The CLI should handle a 403 response

{'message': "API rate limit exceeded for 175.136.21.106. (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'}

and raise the Error in a comprehensible so the user knows that the rate limit is exceeded

@tintinthong
Copy link
Contributor Author

Personally, I also have an opinion about the use of --token flag. I believe the CLI should automatically load the token even if the --token flag is not specified and read from UNFOLLOW_TOKEN. That can be another issue @TechWiz-3 if you want.

@tintinthong tintinthong changed the title Explicitly return Error for when rate limit is exceeded Explicitly return Error when GITHUB API rate limit is exceeded Oct 10, 2022
@TechWiz-3
Copy link
Owner

Love this, thanks a lot for making this issue. Would you like to be assigned?

@tintinthong
Copy link
Contributor Author

Love this, thanks a lot for making this issue. Would you like to be assigned?

Sure sounds good!

@TechWiz-3
Copy link
Owner

TechWiz-3 commented Oct 25, 2022

Any updates @tintinthong? No rush, just let me know

@tintinthong
Copy link
Contributor Author

Any updates @tintinthong? No rush, just let me know

Hi sorry. I will not work on this anymore. Sorry. Thanks for letting me participate in Octoberfest. Cheers!

@tintinthong tintinthong removed their assignment Nov 7, 2022
@TechWiz-3
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants