From ffaea83292eeca7f420523b5ffa273869b13e80b Mon Sep 17 00:00:00 2001 From: wangjifeng Date: Sat, 25 Apr 2026 09:48:47 +0800 Subject: [PATCH] fix(auth): use str(e.code) comparison and cover BudgetExceededError in expected-failure guard --- litellm/proxy/auth/auth_exception_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/auth/auth_exception_handler.py b/litellm/proxy/auth/auth_exception_handler.py index af048906650..30a1c4791c5 100644 --- a/litellm/proxy/auth/auth_exception_handler.py +++ b/litellm/proxy/auth/auth_exception_handler.py @@ -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(