TechWiz-3 / who-unfollowed-me

😡 Python CLI tool that shows you who has unfollowed you on GitHub. PRs welcome!
GNU General Public License v3.0
11 stars 25 forks source link

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

Open tintinthong opened 1 year ago

tintinthong commented 1 year ago

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/python@3.10/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/python@3.10/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/python@3.10/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 commented 1 year ago

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.

TechWiz-3 commented 1 year ago

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

tintinthong commented 1 year ago

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

Sure sounds good!

TechWiz-3 commented 1 year ago

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

tintinthong commented 1 year ago

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!

TechWiz-3 commented 1 year ago

👍