fix(proxy): persist only the router settings keys the request set

This commit is contained in:
mateo-berri 2026-09-18 14:01:05 -07:00
parent acfe9a899a
commit 6449632c7b
3 changed files with 27 additions and 2 deletions

View file

@ -16982,7 +16982,9 @@ async def update_config(
}
)
typed_router_settings: Final[Mapping[str, JsonValue]] = (
config_info.router_settings.model_dump(exclude_none=True) if config_info.router_settings is not None else {}
config_info.router_settings.model_dump(exclude_none=True, exclude_unset=True)
if config_info.router_settings is not None
else {}
)
router_settings_updates: Final[Mapping[str, JsonValue]] = {
**typed_router_settings,

View file

@ -197,6 +197,29 @@ def test_config_update_persists_only_the_general_settings_keys_the_request_set(
assert persisted == {"alerting_threshold": 600}
def test_config_update_persists_only_the_router_settings_keys_the_request_set(
client, auth_as, mock_prisma, monkeypatch
):
from litellm.proxy import proxy_server as ps
from litellm.proxy._types import LitellmUserRoles
table = _install_litellm_config(mock_prisma)
monkeypatch.setattr(ps, "prisma_client", mock_prisma)
monkeypatch.setattr(ps.proxy_config, "add_deployment", AsyncMock())
ps.proxy_config.router_settings.load_yaml({"model_group_alias": {"opus": "claude-opus-5"}})
try:
with auth_as(LitellmUserRoles.PROXY_ADMIN):
response = client.post(
"/config/update", json={"router_settings": {"retry_policy": {"TimeoutErrorRetries": 3}}}
)
finally:
ps.proxy_config.router_settings.load_yaml({})
assert response.status_code == 200, response.text
persisted = json.loads(table.upsert.call_args.kwargs["data"]["create"]["param_value"])
assert persisted == {"retry_policy": {"TimeoutErrorRetries": 3}}
def test_config_update_accepts_a_config_owned_success_callback_the_file_spells_in_mixed_case(
client, auth_as, mock_prisma, monkeypatch
):

View file

@ -360,7 +360,7 @@ async def test_config_update_persists_and_reads_back_retry_policy(monkeypatch):
async def _apply_router_settings(*args, **kwargs):
await proxy_server.proxy_config._add_router_settings_from_db_config(
config_data={}, llm_router=router, prisma_client=prisma_client
llm_router=router, prisma_client=prisma_client
)
monkeypatch.setattr(proxy_server, "prisma_client", prisma_client)