raise budget_exceeded in user_api_key_auth

This commit is contained in:
Ishaan Jaff 2024-07-08 12:45:39 -07:00
parent d3fc5d4a17
commit 4202be8e1f
4 changed files with 59 additions and 56 deletions

View file

@ -261,7 +261,7 @@ async def generate_key_fn(
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
)
@ -269,7 +269,7 @@ async def generate_key_fn(
raise e
raise ProxyException(
message="Authentication Error, " + str(e),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=status.HTTP_400_BAD_REQUEST,
)
@ -374,7 +374,7 @@ async def update_key_fn(
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
)
@ -382,7 +382,7 @@ async def update_key_fn(
raise e
raise ProxyException(
message="Authentication Error, " + str(e),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=status.HTTP_400_BAD_REQUEST,
)
@ -427,7 +427,7 @@ async def delete_key_fn(
if len(keys) == 0:
raise ProxyException(
message=f"No keys provided, passed in: keys={keys}",
type="auth_error",
type=ProxyErrorTypes.auth_error,
param="keys",
code=status.HTTP_400_BAD_REQUEST,
)
@ -505,7 +505,7 @@ async def delete_key_fn(
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
)
@ -513,7 +513,7 @@ async def delete_key_fn(
raise e
raise ProxyException(
message="Authentication Error, " + str(e),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=status.HTTP_400_BAD_REQUEST,
)
@ -580,7 +580,7 @@ async def info_key_fn_v2(
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
)
@ -588,7 +588,7 @@ async def info_key_fn_v2(
raise e
raise ProxyException(
message="Authentication Error, " + str(e),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=status.HTTP_400_BAD_REQUEST,
)
@ -652,7 +652,7 @@ async def info_key_fn(
if isinstance(e, HTTPException):
raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
)
@ -660,7 +660,7 @@ async def info_key_fn(
raise e
raise ProxyException(
message="Authentication Error, " + str(e),
type="auth_error",
type=ProxyErrorTypes.auth_error,
param=getattr(e, "param", "None"),
code=status.HTTP_400_BAD_REQUEST,
)