-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem
The backend returns the following headers on 429 responses:
X-RateLimit-Limit-PerMinuteX-RateLimit-Remaining-PerMinuteX-RateLimit-Limit-PerDayX-RateLimit-Remaining-PerDayRetry-After
The SDK currently only parses Retry-After and discards the rest. Callers have no way to know which limit was hit or what the limit value is, making it impossible to implement informed backoff or meaningful error messages.
Proposed Behaviour
Parse all rate limit response headers and expose them as fields on RateLimitError.
except RateLimitError as e:
print(e.retry_after) # seconds to wait
print(e.limit_per_minute) # per-minute cap, or None
print(e.limit_per_day) # per-day cap, or NoneFiles to Modify
| File | Change |
|---|---|
src/brainus_ai/exceptions.py |
Add limit_per_minute, limit_per_day fields to RateLimitError |
src/brainus_ai/client.py |
Parse additional headers in _make_request error handler |
Acceptance Criteria
-
RateLimitError.retry_afterbehaviour is unchanged -
RateLimitError.limit_per_minuteset when header is present -
RateLimitError.limit_per_dayset when header is present - Fields are
Nonewhen the corresponding header is absent - Tests cover both per-minute and per-day header scenarios
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels