mfuentesg / SyncSettings

Sync Settings - The cross-platform solution to keep Sublime Text configuration synchronized
https://mfuentesg.dev/SyncSettings
MIT License
288 stars 38 forks source link

GitHub API rate limit exceeded #124

Closed mwilliammyers closed 5 years ago

mwilliammyers commented 5 years ago

Thanks for this awesome plugin! I have used it many times without any issues but ran into a rate limit issue...

This is most likely the same issue as #122, but restarting it did not fix it. The error message is pretty confusing because I most likely ran into the rate limit error by re-trying the download after receiving a The credentials are invalid, or the token does not have permissions error popup.

Is there anyway to make an authenticated request to use the higher rate limit? Not sure what kind of requests are going on- I haven't looked into the code.

My config:

{
    "access_token": "...",
    "gist_id": "..."
}

Error log:

WARNING:Sync Settings.sync_settings.libs.logger:{'message': "API rate limit exceeded for <IP ADDRESS>. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", 'documentation_url': 'https://developer.github.com/v3/#rate-limiting'}
ERROR:Sync Settings.sync_settings.libs.logger:The credentials are invalid, or the token does not have permissions
Traceback (most recent call last):
  File "~/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/commands/download.py", line 45, in download
    ).get(settings.get('gist_id'))
  File "~/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/libs/gist.py", line 46, in with_gid_wrapper
    return func(self, *args, **kwargs)
  File "~/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/libs/gist.py", line 83, in get
    return self.__do_request('get', self.make_uri(gid)).json()
  File "~/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/libs/gist.py", line 100, in __do_request
    raise AuthenticationError('The credentials are invalid, or the token does not have permissions')
Sync Settings.sync_settings.libs.gist.AuthenticationError: The credentials are invalid, or the token does not have permissions
mwilliammyers commented 5 years ago

This might be a separate issue, but before hitting the rate limit, my logs looked like:

[a bunch of DEBUG:Six output]
...
DEBUG:Six.lib.motions:executing @Motion<j> times None in mode normal
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '14'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '67'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '69'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '67'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '69'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '71'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '70'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '72'
DEBUG:Six.plugin.window_settings:setting window setting 'alternate_view' to '73
'ERROR:Sync Settings.sync_settings.libs.logger:'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/wm/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/commands/download.py", line 58, in download
    diff = set(package_settings.get(setting)).difference(set(local_settings.get(setting)))
TypeError: 'NoneType' object is not iterable
ERROR:Sync Settings.sync_settings.libs.logger:'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/wm/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/commands/download.py", line 58, in download
    diff = set(package_settings.get(setting)).difference(set(local_settings.get(setting)))
TypeError: 'NoneType' object is not iterable
ERROR:Sync Settings.sync_settings.libs.logger:'NoneType' object is not iterable
Traceback (most recent call last):
  File "/Users/wm/Library/Application Support/Sublime Text 3/Installed Packages/Sync Settings.sublime-package/sync_settings/commands/download.py", line 58, in download
    diff = set(package_settings.get(setting)).difference(set(local_settings.get(setting)))
TypeError: 'NoneType' object is not iterable

Which is weird because six should not even be installed (this is a fresh install of sublime and it is not listed in my gist under installed_packages...)

mfuentesg commented 5 years ago

are you that access_token setting is defined?, because this error in general is raised by not authenticated request.

mwilliammyers commented 5 years ago

I am positive it is defined. Well at least my config looks like:

{
    "access_token": "copy and pasted from my GitHub settings",
    "gist_id": "copy and pasted from the gist's URL"
}

I am definitely getting a rate limit warning:

WARNING:Sync Settings.sync_settings.libs.logger:{'message': "API rate limit exceeded for <IP ADDRESS>. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", 'documentation_url': 'https://developer.github.com/v3/#rate-limiting'}

And I know that is the issue causing the The credentials are invalid, or the token does not have permissions popup because I waited a while and without changing anything it worked...

I think we should at the very least signal this to the user in the popup or display the error message returned from GitHub instead of the generic The credentials are invalid... for all GitHub API errors.

mfuentesg commented 5 years ago

let me check, i guess the download command is not using the defined access_token

mfuentesg commented 5 years ago

@mwilliammyers , please let me know if with the new version you are able to download again without restrictions

mwilliammyers commented 5 years ago

Ok, thanks! I updated it and downloaded my settings 10+ times as fast as I could and it worked. I will keep my eye out from now on as I use it normally.

mfuentesg commented 5 years ago

Thanks William