psss / did

What did you do last week, month, year?
https://did.readthedocs.io/
GNU General Public License v2.0
246 stars 104 forks source link

Traceback while fetching GitHub content #282

Closed sandrobonazzola closed 1 year ago

sandrobonazzola commented 1 year ago
$ rpm -qv did
did-0.19-3.fc37.noarch

While fetching GitHub content I got:

Traceback (most recent call last):
  File "/usr/bin/did", line 42, in <module>
    did.cli.main()
  File "/usr/lib/python3.11/site-packages/did/cli.py", line 223, in main
    user_stats.check()
  File "/usr/lib/python3.11/site-packages/did/stats.py", line 157, in check
    stat.check()
  File "/usr/lib/python3.11/site-packages/did/stats.py", line 157, in check
    stat.check()
  File "/usr/lib/python3.11/site-packages/did/stats.py", line 77, in check
    self.fetch()
  File "/usr/lib/python3.11/site-packages/did/plugins/github.py", line 132, in fetch
    Issue(issue) for issue in self.parent.github.search(query)]
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/did/plugins/github.py", line 79, in search
    data = json.loads(response.text)["items"]
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'items'
mikelolasagasti commented 1 year ago

Can you run it with --debug?

I think I've been able to reproduce and get a DEBUG GitHub status code: 403, after a 'X-RateLimit-Remaining': '0' but would like to confirm.

Do you have a token configured for your github config for did?

DEBUG  Response headers:
{'Date': 'Mon, 28 Nov 2022 10:38:24 GMT', 'Server': 'Varnish', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'deny', 'X-XSS-Protection': '1; mode=block', 'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'", 'Access-Control-Allow-Origin': '*', 'Access-Control-Expose-Headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Used, X-RateLimit-Resource, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'Content-Type': 'application/json; charset=utf-8', 'Referrer-Policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'X-GitHub-Media-Type': 'github.v3; format=json', 'X-RateLimit-Limit': '10', 'X-RateLimit-Remaining': '0', 'X-RateLimit-Reset': '1669631940', 'X-RateLimit-Resource': 'search', 'X-RateLimit-Used': '10', 'Content-Length': '278', 'X-GitHub-Request-Id': 'CDXX:XXXXX:XXXXXXXX:XXXXXXXXXXXXXXX'}

DEBUG  GitHub status code: 403
sandrobonazzola commented 1 year ago

I can confirm I have 'X-RateLimit-Remaining': '0' and DEBUG GitHub status code: 403 when the traceback happens. I have no token set for GitHub.

mikelolasagasti commented 1 year ago

This traceback is already fixed by https://github.com/psss/did/commit/6cf907c5050f4ff331bf947c97a49d9b47963113 but not part of a release.

You should create a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token as otherwise you've 10 requests per minute limit rather than 5000 per hour.

sandrobonazzola commented 1 year ago

confirmed fixed