diff --git a/litellm/router.py b/litellm/router.py index 159e8a7d55e..c72dedc26df 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -9757,11 +9757,13 @@ class Router: if value is None or isinstance(value, RetryPolicy): setattr(self, var, value) elif var == "default_litellm_params": - self.default_litellm_params = {**self.default_litellm_params, **kwargs[var]} + if kwargs[var] is not None: + self.default_litellm_params = {**self.default_litellm_params, **kwargs[var]} elif var == "optional_pre_call_checks": - new_checks = [check for check in kwargs[var] if check not in self.optional_pre_call_checks] - if new_checks: - self.add_optional_pre_call_checks(new_checks) + if kwargs[var] is not None: + new_checks = [check for check in kwargs[var] if check not in self.optional_pre_call_checks] + if new_checks: + self.add_optional_pre_call_checks(new_checks) else: value = kwargs[var] # only run routing strategy init if it has changed diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.py index f1e85e6723a..132d6597149 100644 --- a/tests/test_litellm/test_router.py +++ b/tests/test_litellm/test_router.py @@ -5401,3 +5401,21 @@ def test_get_settings_includes_default_litellm_params_and_optional_pre_call_chec assert settings["optional_pre_call_checks"] == ["prompt_caching"] assert "default_litellm_params" in settings assert isinstance(settings["default_litellm_params"], dict) + + +def test_update_settings_tolerates_null_default_litellm_params_and_optional_pre_call_checks(): + """ + Regression test: `_add_router_settings_from_db_config` calls + `update_settings(**combined_router_settings)` with the raw dict merged from + config.yaml and the DB router_settings row - neither is filtered through + `UpdateRouterConfig(exclude_none=True)` first, so an explicit + `default_litellm_params: null` / `optional_pre_call_checks: null` in either + source reaches update_settings verbatim. `{**dict, **None}` and iterating + `None` both raise TypeError, which would crash proxy startup / config sync. + """ + router = _make_router_for_settings_tests(timeout=42) + + router.update_settings(default_litellm_params=None, optional_pre_call_checks=None) + + assert router.default_litellm_params["timeout"] == 42 + assert router.optional_pre_call_checks == []