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

fix: inconsistence in 429 handling between sync/async client #131

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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