fix(fallback): replace a stored router_settings row that holds a non-JSON string

This commit is contained in:
mateo-berri 2026-10-29 05:50:42 -07:00
parent fb5bad80ef
commit 9f8fd4ac94
2 changed files with 5 additions and 2 deletions

View file

@ -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)

View file

@ -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)