mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix(user_api_key_cache): fix check to not raise error if team object is missing
This commit is contained in:
parent
6c0506a144
commit
b77edc59ed
6 changed files with 34 additions and 22 deletions
|
@ -463,25 +463,29 @@ async def user_api_key_auth(
|
|||
and valid_token.team_id is not None
|
||||
):
|
||||
## UPDATE TEAM VALUES BASED ON CACHED TEAM OBJECT - allows `/team/update` values to work for cached token
|
||||
team_obj: LiteLLM_TeamTableCachedObj = await get_team_object(
|
||||
team_id=valid_token.team_id,
|
||||
prisma_client=prisma_client,
|
||||
user_api_key_cache=user_api_key_cache,
|
||||
parent_otel_span=parent_otel_span,
|
||||
proxy_logging_obj=proxy_logging_obj,
|
||||
)
|
||||
try:
|
||||
team_obj: LiteLLM_TeamTableCachedObj = await get_team_object(
|
||||
team_id=valid_token.team_id,
|
||||
prisma_client=prisma_client,
|
||||
user_api_key_cache=user_api_key_cache,
|
||||
parent_otel_span=parent_otel_span,
|
||||
proxy_logging_obj=proxy_logging_obj,
|
||||
check_cache_only=True,
|
||||
)
|
||||
|
||||
if (
|
||||
team_obj.last_refreshed_at is not None
|
||||
and valid_token.last_refreshed_at is not None
|
||||
and team_obj.last_refreshed_at > valid_token.last_refreshed_at
|
||||
):
|
||||
team_obj_dict = team_obj.__dict__
|
||||
if (
|
||||
team_obj.last_refreshed_at is not None
|
||||
and valid_token.last_refreshed_at is not None
|
||||
and team_obj.last_refreshed_at > valid_token.last_refreshed_at
|
||||
):
|
||||
team_obj_dict = team_obj.__dict__
|
||||
|
||||
for k, v in team_obj_dict.items():
|
||||
field_name = f"team_{k}"
|
||||
if field_name in valid_token.__fields__:
|
||||
setattr(valid_token, field_name, v)
|
||||
for k, v in team_obj_dict.items():
|
||||
field_name = f"team_{k}"
|
||||
if field_name in valid_token.__fields__:
|
||||
setattr(valid_token, field_name, v)
|
||||
except Exception as e:
|
||||
verbose_logger.warning(e)
|
||||
|
||||
try:
|
||||
is_master_key_valid = secrets.compare_digest(api_key, master_key) # type: ignore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue