From de0047c802d906251b6fde03b4a1a7ebf1c3cd8e Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 17 Sep 2026 23:24:26 +0000 Subject: [PATCH] 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> --- .../model_allowlist_rename_sync.py | 2 ++ .../test_model_management_endpoints.py | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/litellm/proxy/management_helpers/model_allowlist_rename_sync.py b/litellm/proxy/management_helpers/model_allowlist_rename_sync.py index d0857aae748..1e92c383f01 100644 --- a/litellm/proxy/management_helpers/model_allowlist_rename_sync.py +++ b/litellm/proxy/management_helpers/model_allowlist_rename_sync.py @@ -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: diff --git a/tests/test_litellm/proxy/management_endpoints/test_model_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_model_management_endpoints.py index d164fa28c10..0f273ebce84 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_model_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_model_management_endpoints.py @@ -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)