From 94293c14bdeb0cbaf7ed534607f9c5958214edc8 Mon Sep 17 00:00:00 2001 From: Ejiro Asiuwhu Date: Thu, 26 Mar 2026 11:19:01 +0100 Subject: [PATCH] fix: raise RateLimitError when 429 retries are exhausted RateLimitError was defined and exported but could never be raised. When all retry attempts are exhausted on a 429 response, _parse_response now raises RateLimitError instead of a generic StackAuthError. Callers writing `except RateLimitError` will now correctly catch rate limit failures. --- sdks/implementations/python/src/stack_auth/_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdks/implementations/python/src/stack_auth/_client.py b/sdks/implementations/python/src/stack_auth/_client.py index 511af7f69..1b1fa0dab 100644 --- a/sdks/implementations/python/src/stack_auth/_client.py +++ b/sdks/implementations/python/src/stack_auth/_client.py @@ -17,7 +17,7 @@ import httpx from stack_auth._constants import API_VERSION, DEFAULT_BASE_URL, SDK_NAME from stack_auth._version import __version__ -from stack_auth.errors import StackAuthError +from stack_auth.errors import RateLimitError, StackAuthError HttpxClientT = TypeVar("HttpxClientT", httpx.Client, httpx.AsyncClient) @@ -116,6 +116,10 @@ class BaseAPIClient(Generic[HttpxClientT]): return actual_status, response.json() return actual_status, None + # Rate limit (429 that exhausted retries) + if actual_status == 429: + raise RateLimitError(code="RATE_LIMIT_EXCEEDED", message="Rate limit exceeded after retries") + # Unrecognised error raise StackAuthError(code="HTTP_ERROR", message=f"HTTP {actual_status}")