diff --git a/litellm/proxy/management_endpoints/fallback_management_endpoints.py b/litellm/proxy/management_endpoints/fallback_management_endpoints.py index 0a73731822f..fe8532185d9 100644 --- a/litellm/proxy/management_endpoints/fallback_management_endpoints.py +++ b/litellm/proxy/management_endpoints/fallback_management_endpoints.py @@ -60,7 +60,10 @@ async def _reload_config_file_ownership(proxy_config: "ProxyConfig") -> None: async def _stored_router_settings(prisma_client: PrismaClient) -> Mapping[str, JsonValue]: - row: Final = await ConfigRepository(prisma_client, use_writer=True).get_param(ROUTER_SETTINGS_PARAM) + try: + row: Final = await ConfigRepository(prisma_client, use_writer=True).get_param(ROUTER_SETTINGS_PARAM) + except json.JSONDecodeError: + return {} if row is None or not isinstance(row.param_value, Mapping): return {} return _STORED_ROUTER_SETTINGS.validate_python(row.param_value) diff --git a/tests/unit/proxy/test_fallback_management_endpoints.py b/tests/unit/proxy/test_fallback_management_endpoints.py index 8feecfe2f9f..5661487cf14 100644 --- a/tests/unit/proxy/test_fallback_management_endpoints.py +++ b/tests/unit/proxy/test_fallback_management_endpoints.py @@ -435,7 +435,7 @@ class TestFallbackWritesSeeTheLatestStoredRules: assert stored.stored_fallbacks() == [GATEWAY_RULE] - @pytest.mark.parametrize("param_value", [None, ["team-primary"], 7]) + @pytest.mark.parametrize("param_value", [None, ["team-primary"], 7, "not json"]) async def test_a_create_replaces_a_stored_row_that_is_not_an_object(self, param_value: JsonValue) -> None: stored: Final = _StoredRouterSettings(None) stored.row = SimpleNamespace(param_name="router_settings", param_value=param_value)