diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 8002863217d..e337222199a 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -1657,8 +1657,8 @@ class ProxyConfig: return copy.deepcopy(self.config) except Exception as e: verbose_proxy_logger.debug( - "ProxyConfig:get_config_state(): Error returning copy of config state. self.config={}\nError: {}".format( - self.config, e + "ProxyConfig:get_config_state(): Error returning copy of config state. self.config={}".format( + self.config ) ) return {} diff --git a/tests/proxy_unit_tests/test_proxy_utils.py b/tests/proxy_unit_tests/test_proxy_utils.py index dd018f674ff..2b63ba5a8b8 100644 --- a/tests/proxy_unit_tests/test_proxy_utils.py +++ b/tests/proxy_unit_tests/test_proxy_utils.py @@ -1107,6 +1107,29 @@ def test_proxy_config_state_post_init_callback_call(): assert config["litellm_settings"]["default_team_settings"][0]["team_id"] == "test" +def test_proxy_config_state_get_config_state_error(): + """ + Ensures that get_config_state does not raise an error when the config is not a valid dictionary + """ + from litellm.proxy.proxy_server import ProxyConfig + import threading + + test_config = { + "callback_list": [ + { + "lock": threading.RLock(), # This will cause the deep copy to fail + "name": "test_callback", + } + ], + "model_list": ["gpt-4", "claude-3"], + } + + pc = ProxyConfig() + pc.config = test_config + config = pc.get_config_state() + assert config == {} + + @pytest.mark.parametrize( "associated_budget_table, expected_user_api_key_auth_key, expected_user_api_key_auth_value", [