Skip to content

Commit 32d0aff

Browse files
authored
fix: inconsistence in 429 handling between sync/async client (#131)
2 parents e2ce832 + 4915b57 commit 32d0aff

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

openfga_sdk/rest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
RateLimitExceededError,
2828
ServiceException,
2929
UnauthorizedException,
30+
ValidationException,
3031
)
3132

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

176177
if not 200 <= r.status <= 299:
178+
if r.status == 400:
179+
raise ValidationException(http_resp=r)
180+
177181
if r.status == 401:
178182
raise UnauthorizedException(http_resp=r)
179183

openfga_sdk/sync/rest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
ApiValueError,
2525
ForbiddenException,
2626
NotFoundException,
27+
RateLimitExceededError,
2728
ServiceException,
2829
UnauthorizedException,
2930
ValidationException,
@@ -252,6 +253,9 @@ def request(
252253
if r.status == 404:
253254
raise NotFoundException(http_resp=r)
254255

256+
if r.status == 429:
257+
raise RateLimitExceededError(http_resp=r)
258+
255259
if 500 <= r.status <= 599:
256260
raise ServiceException(http_resp=r)
257261

0 commit comments

Comments
 (0)