mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-06 07:48:06 +00:00
fix(fallback): compare a restated config-file rule against its resolved env value
This commit is contained in:
parent
9f8fd4ac94
commit
d8e8dcef53
2 changed files with 14 additions and 1 deletions
|
|
@ -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 [])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue