-
Notifications
You must be signed in to change notification settings - Fork 5k
feat: add InsufficientQuotaError for insufficient_quota 429 responses #3507
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -691,6 +691,8 @@ def _make_status_error( | |
| return _exceptions.UnprocessableEntityError(err_msg, response=response, body=data) | ||
|
|
||
| if response.status_code == 429: | ||
| if is_mapping(data) and data.get("code") == "insufficient_quota": | ||
| return _exceptions.InsufficientQuotaError(err_msg, response=response, body=data) | ||
|
Comment on lines
693
to
+695
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With the default Useful? React with 👍 / 👎. |
||
| return _exceptions.RateLimitError(err_msg, response=response, body=data) | ||
|
|
||
| if response.status_code >= 500: | ||
|
|
@@ -1297,6 +1299,8 @@ def _make_status_error( | |
| return _exceptions.UnprocessableEntityError(err_msg, response=response, body=data) | ||
|
|
||
| if response.status_code == 429: | ||
| if is_mapping(data) and data.get("code") == "insufficient_quota": | ||
| return _exceptions.InsufficientQuotaError(err_msg, response=response, body=data) | ||
| return _exceptions.RateLimitError(err_msg, response=response, body=data) | ||
|
|
||
| if response.status_code >= 500: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fresh evidence after the retry fix: for
stream=True/.with_streaming_responsecalls,_base_client.request()sends the request with streaming enabled, so the 429 body has not been read when this line callsresponse.json(); httpx raisesResponseNotRead, the broadexceptturns the body intoNone, and the code falls through to retry. Streaming chat/responses requests that receivecode="insufficient_quota"will therefore still burnmax_retriesbefore raising, unlike the non-streaming path covered by the new tests.Useful? React with 👍 / 👎.