From d8e8dcef53ff32bb0f967949bbd4375c6b648af4 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 29 Oct 2026 07:22:11 -0700 Subject: [PATCH] fix(fallback): compare a restated config-file rule against its resolved env value --- .../fallback_management_endpoints.py | 2 +- .../proxy/test_fallback_management_endpoints.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/fallback_management_endpoints.py b/litellm/proxy/management_endpoints/fallback_management_endpoints.py index fe8532185d9..ec8ee5ca213 100644 --- a/litellm/proxy/management_endpoints/fallback_management_endpoints.py +++ b/litellm/proxy/management_endpoints/fallback_management_endpoints.py @@ -75,7 +75,7 @@ def _editable_rules( file_settings: Final = proxy_config.router_settings if not file_settings.owned_by_config(fallback_key): return _STORED_FALLBACKS.validate_python(stored_settings.get(fallback_key) or []) - file_rules: Final = file_settings.config_value(fallback_key) + file_rules: Final = file_settings.get(fallback_key) return _STORED_FALLBACKS.validate_python(file_rules if isinstance(file_rules, list) else []) diff --git a/tests/unit/proxy/test_fallback_management_endpoints.py b/tests/unit/proxy/test_fallback_management_endpoints.py index 5661487cf14..4a0e8cb7a9a 100644 --- a/tests/unit/proxy/test_fallback_management_endpoints.py +++ b/tests/unit/proxy/test_fallback_management_endpoints.py @@ -566,6 +566,19 @@ class TestFallbackWritesHonourTheConfigFile: assert stored.row is None assert router.fallbacks == [CONFIG_RULE, CONFIG_WINDOW_RULE] + async def test_a_create_that_restates_a_config_rule_next_to_an_env_reference_writes_nothing( + self, router: Router, monkeypatch: pytest.MonkeyPatch + ) -> None: + monkeypatch.setenv("LITELLM_TEST_FALLBACK_MODEL", "team-fallback") + env_rule: Final = {"team-primary": "os.environ/LITELLM_TEST_FALLBACK_MODEL"} + stored: Final = _StoredRouterSettings(None, config_file={"fallbacks": [CONFIG_RULE, env_rule]}) + request: Final = FallbackCreateRequest(model="gpt-5.4-mini", fallback_models=["team-fallback"]) + + response: Final = await self._create(request, router, stored) + + assert response.fallback_models == ["team-fallback"] + assert stored.row is None + async def test_a_create_that_restates_the_config_rule_is_accepted( self, router: Router, stored: _StoredRouterSettings ) -> None: