forked from phoenix/litellm-mirror
(fix) fix error message raised on passing invalid tokens
This commit is contained in:
parent
6ee6fb6c73
commit
fd93a68b0d
2 changed files with 5 additions and 2 deletions
|
@ -889,6 +889,9 @@ async def user_api_key_auth(
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"This key is made for LiteLLM UI, Tried to access route: {route}. Not allowed"
|
f"This key is made for LiteLLM UI, Tried to access route: {route}. Not allowed"
|
||||||
)
|
)
|
||||||
|
if valid_token is None:
|
||||||
|
# No token was found when looking up in the DB
|
||||||
|
raise Exception("Invalid token passed")
|
||||||
if valid_token_dict is not None:
|
if valid_token_dict is not None:
|
||||||
return UserAPIKeyAuth(api_key=api_key, **valid_token_dict)
|
return UserAPIKeyAuth(api_key=api_key, **valid_token_dict)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -158,7 +158,7 @@ def test_call_with_invalid_key(prisma_client):
|
||||||
|
|
||||||
async def test():
|
async def test():
|
||||||
await litellm.proxy.proxy_server.prisma_client.connect()
|
await litellm.proxy.proxy_server.prisma_client.connect()
|
||||||
generated_key = "bad-key"
|
generated_key = "sk-126666"
|
||||||
bearer_token = "Bearer " + generated_key
|
bearer_token = "Bearer " + generated_key
|
||||||
|
|
||||||
request = Request(scope={"type": "http"}, receive=None)
|
request = Request(scope={"type": "http"}, receive=None)
|
||||||
|
@ -173,7 +173,7 @@ def test_call_with_invalid_key(prisma_client):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Got Exception", e)
|
print("Got Exception", e)
|
||||||
print(e.message)
|
print(e.message)
|
||||||
assert "Authentication Error" in e.message
|
assert "Authentication Error, Invalid token passed" in e.message
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue