Skip to content

Commit 94293c1

Browse files
committed
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.
1 parent a6ac188 commit 94293c1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • sdks/implementations/python/src/stack_auth

sdks/implementations/python/src/stack_auth/_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from stack_auth._constants import API_VERSION, DEFAULT_BASE_URL, SDK_NAME
1919
from stack_auth._version import __version__
20-
from stack_auth.errors import StackAuthError
20+
from stack_auth.errors import RateLimitError, StackAuthError
2121

2222
HttpxClientT = TypeVar("HttpxClientT", httpx.Client, httpx.AsyncClient)
2323

@@ -116,6 +116,10 @@ def _parse_response(self, response: httpx.Response) -> tuple[int, dict[str, Any]
116116
return actual_status, response.json()
117117
return actual_status, None
118118

119+
# Rate limit (429 that exhausted retries)
120+
if actual_status == 429:
121+
raise RateLimitError(code="RATE_LIMIT_EXCEEDED", message="Rate limit exceeded after retries")
122+
119123
# Unrecognised error
120124
raise StackAuthError(code="HTTP_ERROR", message=f"HTTP {actual_status}")
121125

0 commit comments

Comments
 (0)