From 4328a66a3a2b40a1fb476e53653a636b51d57aac Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Dec 2023 14:33:28 -0800 Subject: [PATCH] fix(proxy_server.py): don't override exceptions if they're of type httpexception --- litellm/proxy/proxy_server.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 3f94f90b94..c70d67bf12 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -279,10 +279,13 @@ async def user_api_key_auth(request: Request, api_key: str = fastapi.Security(ap raise Exception(f"Invalid token") except Exception as e: print(f"An exception occurred - {traceback.format_exc()}") - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="invalid user key", - ) + if isinstance(e, HTTPException): + raise e + else: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail="invalid user key", + ) def prisma_setup(database_url: Optional[str]): global prisma_client