fix(proxy): skip allowlist rewrite when the model name is unchanged

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
ryan 2026-09-17 23:24:26 +00:00
parent d3f5cde530
commit de0047c802
2 changed files with 24 additions and 0 deletions

View file

@ -95,6 +95,8 @@ async def sync_model_allowlists_for_renamed_model(
llm_router: Router | None,
user_api_key_cache: UserApiKeyCache,
) -> None:
if old_name == new_name:
return
executor: Final = raw_executor(prisma_client)
old_name_still_backed: Final = await still_backed(executor, llm_router, old_name, model_id)
for allowlist in _ALLOWLIST_TABLES:

View file

@ -6315,6 +6315,28 @@ class TestAccessGroupModelSync:
assert 'WHERE $1 = ANY("models") AND NOT ($2 = ANY("models"))' in update_call.args[0]
assert update_call.args[1:] == ("gpt-5.6", "gpt-5.6-eu")
@pytest.mark.asyncio
async def test_unchanged_name_never_touches_allowlists(self):
from litellm.proxy.management_helpers.model_allowlist_rename_sync import (
sync_model_allowlists_for_renamed_model,
)
mock_prisma = self._prisma_with_row("m-rename", "gpt-5.6", deployment_count=0)
evict = AsyncMock()
with patch(self._EVICT, new=evict):
await sync_model_allowlists_for_renamed_model(
prisma_client=mock_prisma,
model_id="m-rename",
old_name="gpt-5.6",
new_name="gpt-5.6",
llm_router=None,
user_api_key_cache=MagicMock(),
)
assert self._allowlist_updates(mock_prisma) == {}
evict.assert_not_awaited()
class TestTeamMemberAutoRouterWrites:
@pytest.fixture(autouse=True)