Merge pull request #3910 from BerriAI/litellm_fix_end_user_max_budget

fix(proxy_server.py): fix end user object check when master key used
This commit is contained in:
Krish Dholakia 2024-05-29 18:04:56 -07:00 committed by GitHub
commit 67973e5344
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 92 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)})"),