refactor: Remove incomplete wildcard validation per maintainer feedback

Per maintainer feedback, removed the wildcard validation logic as it doesn't cover
all auth mechanisms (Google, AWS, etc.).

Keeping only the core improvements:
- Enhanced error messages showing deployment/credential used
- Debug logging for pattern-matched deployments

The validation logic needs more work to handle all provider auth mechanisms properly.
This commit is contained in:
Akiva Kraines
2026-01-05 22:26:46 +02:00
parent fa08f157d8
commit 31430156c7
-34
View File
@@ -5725,37 +5725,6 @@ class Router:
return True
return False
def _validate_wildcard_deployments(self):
"""Warn if multiple wildcard patterns exist for same provider with different credentials"""
provider_wildcards: Dict[str, List[Tuple[str, str]]] = {} # provider -> [(credential, deployment_id)]
for deployment in self.model_list:
model_name = deployment.get('model_name', '')
if '*' in model_name:
# Extract provider from pattern (e.g., "openai/*" -> "openai")
provider = model_name.split('/')[0] if '/' in model_name else model_name.split('*')[0]
litellm_params = deployment.get('litellm_params', {})
# Get credential identifier - use litellm_credential_name or first 10 chars of api_key
credential = litellm_params.get('litellm_credential_name') or \
(litellm_params.get('api_key', '')[:10] if litellm_params.get('api_key') else 'none')
deployment_id = deployment.get('model_info', {}).get('id', 'unknown')
if provider not in provider_wildcards:
provider_wildcards[provider] = []
provider_wildcards[provider].append((credential, deployment_id))
for provider, cred_deployment_pairs in provider_wildcards.items():
unique_credentials = set(cred for cred, _ in cred_deployment_pairs)
if len(unique_credentials) > 1:
deployment_ids = [dep_id for _, dep_id in cred_deployment_pairs]
verbose_router_logger.warning(
f"⚠️ Multiple wildcard deployments found for '{provider}/*' with different credentials ({len(unique_credentials)} credentials). "
f"This may cause non-deterministic authentication failures. "
f"Deployments: {len(cred_deployment_pairs)} ({deployment_ids[:3]}{'...' if len(deployment_ids) > 3 else ''}). "
f"Consider: 1) Using concrete model names, 2) Using one credential per provider, or 3) Using tag-based routing."
)
def set_model_list(self, model_list: list):
original_model_list = copy.deepcopy(model_list)
self.model_list = []
@@ -5805,9 +5774,6 @@ class Router:
# Note: model_name_to_deployment_indices is already built incrementally
# by _create_deployment -> _add_model_to_list_and_index_map
# Validate wildcard deployments after all models are loaded
self._validate_wildcard_deployments()
def _add_deployment(self, deployment: Deployment) -> Deployment:
import os