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

AttributeError: module 'requests.exceptions' has no attribute 'JSONDecodeError' #273

Open
achingbrain opened this issue Sep 23, 2022 · 1 comment

Comments

@achingbrain
Copy link

achingbrain commented Sep 23, 2022

Sometimes I get the following error running did today:

Traceback (most recent call last):
  File "/usr/local/bin/did", line 42, in <module>
    did.cli.main()
  File "/usr/local/lib/python3.9/site-packages/did/cli.py", line 223, in main
    user_stats.check()
  File "/usr/local/lib/python3.9/site-packages/did/stats.py", line 157, in check
    stat.check()
  File "/usr/local/lib/python3.9/site-packages/did/stats.py", line 157, in check
    stat.check()
  File "/usr/local/lib/python3.9/site-packages/did/stats.py", line 77, in check
    self.fetch()
  File "/usr/local/lib/python3.9/site-packages/did/plugins/github.py", line 132, in fetch
    Issue(issue) for issue in self.parent.github.search(query)]
  File "/usr/local/lib/python3.9/site-packages/did/plugins/github.py", line 81, in search
    except requests.exceptions.JSONDecodeError as error:
AttributeError: module 'requests.exceptions' has no attribute 'JSONDecodeError'

It doesn't happen every time, and when it does if I run the command again, eventually it succeeds.

I only have github configured, and my email in [general]:

[github]
type = github
url = https://api.github.com/
login = achingbrain

Running with --debug I guess I've hit a rate limit?

[DEBUG] GitHub query: https://api.github.com/search/issues?q=author:achingbrain+created:2022-09-19..2022-09-26+type:issue&per_page=100\n
[DEBUG] Response headers:
{'Date': 'Fri, 23 Sep 2022 17:03:08 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': '1663952639', 'X-RateLimit-Resource': 'search', 'X-RateLimit-Used': '10', 'Content-Length': '280', 'X-GitHub-Request-Id': 'E5DD:082A:F42FF08:F7C4E6B:632DE6CB'}
[DEBUG] GitHub status code: 403
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/did/plugins/github.py", line 79, in search
    data = json.loads(response.text)["items"]
KeyError: 'items'
@mikelolasagasti
Copy link
Contributor

Correct, the traceback is fixed in 6cf907c

You should create a token to have 5000 limit per hour.

#282 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants