fix(proxy): add defensive type check in add_team_based_callbacks_from_config

load_team_config() should always return a dict, but when proxy_config
is mocked in tests without configuring load_team_config.return_value,
calling .keys() on a Mock object raises TypeError. Adding isinstance
check makes this robust against unexpected return types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Harshit28j 2026-03-04 23:42:30 +05:30
parent b41f770197
commit de4caed83e

View file

@ -799,7 +799,7 @@ class LiteLLMProxyRequestSetup:
Add team-based callbacks from the config
"""
team_config = proxy_config.load_team_config(team_id=team_id)
if len(team_config.keys()) == 0:
if not isinstance(team_config, dict) or len(team_config.keys()) == 0:
return None
callback_vars_dict = {**team_config.get("callback_vars", team_config)}