diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index 8a44a7bab33..42c73729a2b 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -3338,12 +3338,16 @@ def _can_object_call_model( ) # Require a real model-group name; a non-string from a router stub must # never be treated as a grant. - if isinstance(canonical_target, str) and canonical_target and _check_model_access_helper( - model=canonical_target, - llm_router=llm_router, - models=models, - team_model_aliases=team_model_aliases, - team_id=team_id, + if ( + isinstance(canonical_target, str) + and canonical_target + and _check_model_access_helper( + model=canonical_target, + llm_router=llm_router, + models=models, + team_model_aliases=team_model_aliases, + team_id=team_id, + ) ): return True diff --git a/litellm/router.py b/litellm/router.py index 94ca7854233..aee52e50f7b 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -10721,9 +10721,7 @@ class Router: cost_generation: Final = get_model_cost_mutation_generation() if self._canonical_model_index is None or self._canonical_model_index_cost_generation != cost_generation: try: - self._canonical_model_index = build_canonical_index( - cast("list[DeploymentTypedDict]", self.model_list) - ) + self._canonical_model_index = build_canonical_index(cast("list[DeploymentTypedDict]", self.model_list)) except Exception as exc: # noqa: BLE001 # index construction must never brick a router; degrade to 'strict' verbose_router_logger.error("canonical-resolution: index build failed, disabling feature: %s", exc) self._canonical_model_index = {}