From de4caed83e054e8fe07e9640964cbe3968084f00 Mon Sep 17 00:00:00 2001 From: Harshit28j Date: Wed, 4 Mar 2026 23:42:30 +0530 Subject: [PATCH] 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 --- litellm/proxy/litellm_pre_call_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index 32eab99fb99..b46dff5b77f 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -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)}