question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not all APIs have rate limits

See original GitHub issue

When working with the integrations API, I noticed that not all APIs have rate limits, which causes gidgethub to fail hard:

Traceback (most recent call last):
  File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 459, in callback
    self._startRunCallbacks(result)
  File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 567, in _startRunCallbacks
    self._runCallbacks()
  File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 1357, in gotResult
    _inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
  File "/Users/dstufft/.virtualenvs/browntruck/lib/python3.6/site-packages/twisted/internet/defer.py", line 1301, in _inlineCallbacks
    result = g.send(result)
  File "t.py", line 46, in inner
    async for installation in gh.getiter("/integration/installations"):
  File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/abc.py", line 64, in getiter
    authorization)
  File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/abc.py", line 48, in _make_request
    data, self.rate_limit, more = sansio.decipher_response(*response)
  File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/sansio.py", line 267, in decipher_response
    return data, RateLimit.from_http(headers), _next_link(headers.get("link"))
  File "/Users/dstufft/.virtualenvs/browntruck/src/gidgethub/gidgethub/sansio.py", line 211, in from_http
    limit = int(headers["x-ratelimit-limit"])
builtins.KeyError: 'x-ratelimit-limit'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
brettcannoncommented, Jun 13, 2018

[ @eliot1019 edited your message ⬆️ to come off as more 😃 and less 😠 ]

0reactions
brettcannoncommented, Jun 12, 2018

Probably if you update

https://github.com/brettcannon/gidgethub/blob/4d5819cf50f3ad896713364d5e749bea466b9f05/gidgethub/sansio.py#L233-L234

to catch the KeyError and return None instead that should do it (plus tests and docs, of course). If anyone wants to provide a PR I will happily review it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding rate limits for APIs and Plans - IBM
This rate limit applies to all calls involving the API, from all consumer orgs. If the containing Plan allows the call but the...
Read more >
What is API Rate Limiting and How to Implement It - DataDome
API rate limiting is used to ensure your API can provide optimal service for its users, while also ensuring their safety.
Read more >
Everything You Need To Know About API Rate Limiting
This rate-limiting library automatically limits the number of requests that can be sent to an API. It also sets up the request queue ......
Read more >
API Management 101: Rate Limiting - Tyk.io
API -level rate limiting assesses all traffic coming into an API from all sources and ensures that the overall rate limit is not...
Read more >
How to handle API rate limits: Do your integrations work at ...
The different APIs with which a unified API makes connections all carry different rate limits and have standards in place to deal with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found