fix raise correct error 404 when /key/info is called on non-existent key (#6653)

* fix raise correct error on /key/info

* add not_found_error error

* fix key not found in DB error

* use 1 helper for checking token hash

* fix error code on key info

* fix test key gen prisma

* test_generate_and_call_key_info

* test fix test_call_with_valid_model_using_all_models

* fix key info tests
This commit is contained in:
Ishaan Jaff 2024-11-11 21:00:39 -08:00 committed by GitHub
parent 25bae4cc23
commit de2f9aed3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 3593 additions and 57 deletions

View file

@ -44,14 +44,8 @@ class RouteChecks:
route in LiteLLMRoutes.info_routes.value
): # check if user allowed to call an info route
if route == "/key/info":
# check if user can access this route
query_params = request.query_params
key = query_params.get("key")
if key is not None and hash_token(token=key) != api_key:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="user not allowed to access this key's info",
)
# handled by function itself
pass
elif route == "/user/info":
# check if user can access this route
query_params = request.query_params