Skip to content

Commit

Permalink
fix: inconsistence in 429 handling between sync/async client (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims authored Sep 20, 2024
2 parents e2ce832 + 4915b57 commit 32d0aff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openfga_sdk/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
RateLimitExceededError,
ServiceException,
UnauthorizedException,
ValidationException,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -174,6 +175,9 @@ async def request(
logger.debug("response body: %s", r.data)

if not 200 <= r.status <= 299:
if r.status == 400:
raise ValidationException(http_resp=r)

if r.status == 401:
raise UnauthorizedException(http_resp=r)

Expand Down
4 changes: 4 additions & 0 deletions openfga_sdk/sync/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ApiValueError,
ForbiddenException,
NotFoundException,
RateLimitExceededError,
ServiceException,
UnauthorizedException,
ValidationException,
Expand Down Expand Up @@ -252,6 +253,9 @@ def request(
if r.status == 404:
raise NotFoundException(http_resp=r)

if r.status == 429:
raise RateLimitExceededError(http_resp=r)

if 500 <= r.status <= 599:
raise ServiceException(http_resp=r)

Expand Down

0 comments on commit 32d0aff

Please sign in to comment.