fix(proxy_server.py): fix end user object check when master key used

check if end user max budget exceeded for master key
This commit is contained in:
Krrish Dholakia 2024-05-29 17:20:59 -07:00
parent e9b5bf2d2f
commit cfcf5969c8
4 changed files with 30 additions and 3 deletions

View file

@ -722,6 +722,8 @@ async def user_api_key_auth(
budget_info.max_budget
)
except Exception as e:
if isinstance(e, litellm.BudgetExceededError):
raise e
verbose_proxy_logger.debug(
"Unable to find user in db. Error - {}".format(str(e))
)
@ -1410,6 +1412,10 @@ async def user_api_key_auth(
raise Exception()
except Exception as e:
traceback.print_exc()
if isinstance(e, litellm.BudgetExceededError):
raise ProxyException(
message=e.message, type="auth_error", param=None, code=400
)
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),