Skip to content

Commit

Permalink
feat(app): Cover GitHub API rate limit exceeding w/ a server response
Browse files Browse the repository at this point in the history
Not quite cleanly handled, `gidgethub` has a bug perhaps:
https://github.com/brettcannon/gidgethub/blob/89ade8859539212e0663e91f0777ad8a39ecf323/gidgethub/sansio.py#L341-L342

`rate_limit` is `False` when it shouldn't be?
  • Loading branch information
alexpovel committed Aug 13, 2022
1 parent ec6d394 commit 99c6039
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ancv/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ async def get_resume(
# to deal with.
await github.getitem(f"/users/{user}")
except gidgethub.BadRequest as e:
# Cannot cleanly just catch 404, since e.g. `RateLimitExceeded` inherits from
# `BadRequest`:
# https://gidgethub.readthedocs.io/en/latest/__init__.html#gidgethub.RateLimitExceeded
# `except `RateLimitExceeded` didn't work, it seems it's not correctly raised
# inside `gidgethub`.
if e.status_code == HTTPStatus.FORBIDDEN:
raise ResumeLookupError(
"Server exhausted its GitHub API rate limit, terribly sorry!"
+ " Please try again later."
)
if e.status_code == HTTPStatus.NOT_FOUND:
raise ResumeLookupError(f"User {user} not found.")
raise e
Expand Down

0 comments on commit 99c6039

Please sign in to comment.