mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
fix(auth): use str(e.code) comparison and cover BudgetExceededError in expected-failure guard
This commit is contained in:
parent
3ce9dce87d
commit
ffaea83292
1 changed files with 6 additions and 2 deletions
|
|
@ -80,8 +80,12 @@ class UserAPIKeyAuthExceptionHandler:
|
|||
# flooding error logs with routine access-control events.
|
||||
# All other exceptions are unexpected and logged at ERROR with traceback.
|
||||
_is_expected_auth_failure = (
|
||||
isinstance(e, ProxyException) and int(e.code) in (401, 403)
|
||||
) or (isinstance(e, HTTPException) and e.status_code in (401, 403))
|
||||
isinstance(e, litellm.BudgetExceededError)
|
||||
) or (
|
||||
isinstance(e, ProxyException) and str(e.code) in ("401", "403")
|
||||
) or (
|
||||
isinstance(e, HTTPException) and e.status_code in (401, 403)
|
||||
)
|
||||
if _is_expected_auth_failure:
|
||||
verbose_proxy_logger.warning(
|
||||
"litellm.proxy.proxy_server.user_api_key_auth(): Auth denied - {}\nRequester IP Address:{}".format(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue