mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix(router): handle InternalServerError in get_num_retries_from_retry_policy
RetryPolicy.InternalServerErrorRetries was accepted in config and validated by pydantic but never read at runtime — the resolver had branches for five error types and omitted InternalServerError. Operators who configured per-error 5xx retries silently fell through to the global num_retries default. Added the missing isinstance branch and a regression test. Fixes #37805
This commit is contained in:
parent
ff02d5cfc0
commit
8d0cd8a37f
2 changed files with 9 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ from litellm.exceptions import (
|
|||
AuthenticationError,
|
||||
BadRequestError,
|
||||
ContentPolicyViolationError,
|
||||
InternalServerError,
|
||||
RateLimitError,
|
||||
Timeout,
|
||||
)
|
||||
|
|
@ -26,6 +27,7 @@ def get_num_retries_from_retry_policy(
|
|||
TimeoutErrorRetries: Optional[int] = None
|
||||
RateLimitErrorRetries: Optional[int] = None
|
||||
ContentPolicyViolationErrorRetries: Optional[int] = None
|
||||
InternalServerErrorRetries: Optional[int] = None
|
||||
"""
|
||||
# if we can find the exception then in the retry policy -> return the number of retries
|
||||
|
||||
|
|
@ -50,6 +52,8 @@ def get_num_retries_from_retry_policy(
|
|||
return retry_policy.ContentPolicyViolationErrorRetries
|
||||
if isinstance(exception, BadRequestError) and retry_policy.BadRequestErrorRetries is not None:
|
||||
return retry_policy.BadRequestErrorRetries
|
||||
if isinstance(exception, InternalServerError) and retry_policy.InternalServerErrorRetries is not None:
|
||||
return retry_policy.InternalServerErrorRetries
|
||||
|
||||
|
||||
def reset_retry_policy() -> RetryPolicy:
|
||||
|
|
|
|||
|
|
@ -1354,6 +1354,11 @@ def test_track_deployment_metrics(model_list):
|
|||
"ContentPolicyViolationError",
|
||||
7,
|
||||
),
|
||||
(
|
||||
litellm.exceptions.InternalServerError,
|
||||
"InternalServerError",
|
||||
5,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_get_num_retries_from_retry_policy(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue