From 2f174c38ff12969f85543b39476d383292d056be Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:13:19 -0700 Subject: [PATCH] fix(health): keep an internal team name a wildcard grant admits as its own target --- litellm/proxy/health_endpoints/_health_endpoints.py | 6 +++++- tests/unit/proxy/health_endpoints/test_health_endpoints.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/health_endpoints/_health_endpoints.py b/litellm/proxy/health_endpoints/_health_endpoints.py index 312fbd6b0d3..8545e0609db 100644 --- a/litellm/proxy/health_endpoints/_health_endpoints.py +++ b/litellm/proxy/health_endpoints/_health_endpoints.py @@ -49,6 +49,7 @@ from litellm.proxy.auth.auth_checks import ( can_user_call_model, get_user_object, key_model_aliases_for_auth_check, + model_matches_any_wildcard_pattern_in_list, team_model_aliases_for_auth_check, ) from litellm.proxy.auth.auth_exception_handler import ( @@ -1260,10 +1261,13 @@ class _AccessGroupGrants: def requested_name(self, name: str, public_names: Mapping[str, str], admitted_names: frozenset[str]) -> str: public_name: Final = public_names.get(name) - if public_name is None or public_name not in admitted_names or name in self.granted_names: + if public_name is None or public_name not in admitted_names or self._grants(name): return name return public_name + def _grants(self, name: str) -> bool: + return name in self.granted_names or model_matches_any_wildcard_pattern_in_list(name, tuple(self.granted_names)) + def narrow(self, serving_ids: frozenset[str], served_names: frozenset[str]) -> frozenset[str]: in_granted_groups: Final = serving_ids & self.ids_in_granted_groups granted_directly: Final = not self.granted_names.isdisjoint(served_names) diff --git a/tests/unit/proxy/health_endpoints/test_health_endpoints.py b/tests/unit/proxy/health_endpoints/test_health_endpoints.py index 7a1635ca4b1..2258eb95fb8 100644 --- a/tests/unit/proxy/health_endpoints/test_health_endpoints.py +++ b/tests/unit/proxy/health_endpoints/test_health_endpoints.py @@ -4965,8 +4965,11 @@ async def test_health_endpoint_probes_only_the_access_groups_team_deployments_se @pytest.mark.asyncio -async def test_health_endpoint_probes_a_team_deployment_whose_internal_name_the_key_holds() -> None: - caller: Final = _team_key(["premium", "model_name_team-a_9d2f6e01"]) +@pytest.mark.parametrize("internal_name_grant", ["model_name_team-a_9d2f6e01", "model_name_team-a_*"]) +async def test_health_endpoint_probes_a_team_deployment_whose_internal_name_the_key_holds( + internal_name_grant: str, +) -> None: + caller: Final = _team_key(["premium", internal_name_grant]) probed: Final = await _live_probed_model_ids(_team_split_model_list("gpt-5.4-mini", "openai/gpt-5.4-mini"), caller)