This commit is contained in:
Soroush Ahmadi 2026-09-05 20:50:04 -04:00 • committed by GitHub
commit b6012b2881
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -963,6 +963,7 @@ class Router:
self.fallbacks = [{"*": _fallbacks}]
self.context_window_fallbacks = context_window_fallbacks or litellm.context_window_fallbacks
self.validate_fallbacks(fallback_param=self.context_window_fallbacks)
_content_policy_fallbacks: Final = content_policy_fallbacks or litellm.content_policy_fallbacks
self.validate_fallbacks(fallback_param=_content_policy_fallbacks)

View file

@ -2825,3 +2825,11 @@ def test_upsert_deployment_clears_stale_budget_config(monkeypatch):
router.upsert_deployment(deployment=unbudgeted)
assert budget_limiter._get_budget_config_for_deployment(model_id) is None
def test_context_window_fallbacks_validated_at_init(model_list):
"""Malformed context_window_fallbacks must fail fast like the sibling params (#39655)."""
import pytest
with pytest.raises(ValueError, match="not a dictionary"):
Router(model_list=model_list, context_window_fallbacks=["garbage"])