diff --git a/litellm/proxy/management_endpoints/policy_endpoints.py b/litellm/proxy/management_endpoints/policy_endpoints.py index 2257a2a52d5..f9487dc2e59 100644 --- a/litellm/proxy/management_endpoints/policy_endpoints.py +++ b/litellm/proxy/management_endpoints/policy_endpoints.py @@ -185,9 +185,9 @@ async def get_policy_info( policy_name=policy_name, inherit=policy.inherit, scope=PolicyScopeResponse( - teams=policy.scope.get_teams(), - keys=policy.scope.get_keys(), - models=policy.scope.get_models(), + teams=[], + keys=[], + models=[], ), guardrails=PolicyGuardrailsResponse( add=policy.guardrails.get_add(), @@ -245,9 +245,7 @@ async def test_policy_matching( policies = registry.get_all_policies() # Get matching policies - matching_policy_names = PolicyMatcher.get_matching_policies( - policies=policies, context=context - ) + matching_policy_names = PolicyMatcher.get_matching_policies(context=context) # Resolve guardrails resolved_guardrails = PolicyResolver.resolve_guardrails_for_context( diff --git a/litellm/proxy/policy_engine/attachment_registry.py b/litellm/proxy/policy_engine/attachment_registry.py index b1a2458a6f0..b5d6f2fb745 100644 --- a/litellm/proxy/policy_engine/attachment_registry.py +++ b/litellm/proxy/policy_engine/attachment_registry.py @@ -11,7 +11,6 @@ from litellm._logging import verbose_proxy_logger from litellm.types.proxy.policy_engine import ( PolicyAttachment, PolicyMatchContext, - PolicyScope, ) diff --git a/litellm/proxy/policy_engine/policy_registry.py b/litellm/proxy/policy_engine/policy_registry.py index 490f5fa5f0b..68485f92489 100644 --- a/litellm/proxy/policy_engine/policy_registry.py +++ b/litellm/proxy/policy_engine/policy_registry.py @@ -13,7 +13,6 @@ from litellm._logging import verbose_proxy_logger from litellm.types.proxy.policy_engine import ( Policy, PolicyCondition, - PolicyConfig, PolicyGuardrails, ) diff --git a/litellm/proxy/policy_engine/policy_resolver.py b/litellm/proxy/policy_engine/policy_resolver.py index 2df761e093d..cfdedc467d8 100644 --- a/litellm/proxy/policy_engine/policy_resolver.py +++ b/litellm/proxy/policy_engine/policy_resolver.py @@ -8,7 +8,7 @@ Handles: - Combining guardrails from multiple matching policies """ -from typing import Any, Dict, List, Optional, Set +from typing import Dict, List, Optional, Set from litellm._logging import verbose_proxy_logger from litellm.types.proxy.policy_engine import ( diff --git a/litellm/proxy/policy_engine/policy_validator.py b/litellm/proxy/policy_engine/policy_validator.py index 01c6e0735aa..f79fb8bfa9c 100644 --- a/litellm/proxy/policy_engine/policy_validator.py +++ b/litellm/proxy/policy_engine/policy_validator.py @@ -12,7 +12,6 @@ Validates: from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set from litellm._logging import verbose_proxy_logger -from litellm.proxy.auth.route_checks import RouteChecks from litellm.types.proxy.policy_engine import ( Policy, PolicyValidationError, @@ -267,53 +266,8 @@ class PolicyValidator: ) ) - # Validate team aliases (non-wildcard only, query per alias) - if validate_db and self.prisma_client: - for team_pattern in policy.scope.get_teams(): - if not self.is_wildcard_pattern(team_pattern): - exists = await self.check_team_alias_exists(team_alias=team_pattern) - if not exists: - warnings.append( - PolicyValidationError( - policy_name=policy_name, - error_type=PolicyValidationErrorType.INVALID_TEAM, - message=f"Team alias '{team_pattern}' not found in database", - field="scope.teams", - value=team_pattern, - ) - ) - - # Validate key aliases (non-wildcard only, query per alias) - if validate_db and self.prisma_client: - for key_pattern in policy.scope.get_keys(): - if not self.is_wildcard_pattern(key_pattern): - exists = await self.check_key_alias_exists(key_alias=key_pattern) - if not exists: - warnings.append( - PolicyValidationError( - policy_name=policy_name, - error_type=PolicyValidationErrorType.INVALID_KEY, - message=f"Key alias '{key_pattern}' not found in database", - field="scope.keys", - value=key_pattern, - ) - ) - - # Validate models (non-wildcard only, check against router) - if self.llm_router: - for model_pattern in policy.scope.get_models(): - if not self.is_wildcard_pattern(model_pattern): - exists = self.check_model_exists(model=model_pattern) - if not exists: - warnings.append( - PolicyValidationError( - policy_name=policy_name, - error_type=PolicyValidationErrorType.INVALID_MODEL, - message=f"Model '{model_pattern}' not found in router", - field="scope.models", - value=model_pattern, - ) - ) + # Note: Team, key, and model validation is done via policy_attachments + # Policies no longer have scope - attachments define where policies apply # Validate inheritance inheritance_errors = self._validate_inheritance_chain( diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index eb4d6bd1501..8500d820a4c 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2869,12 +2869,6 @@ class ProxyConfig: verbose_proxy_logger.info(f"Policy engine: found {len(policies_config)} policies in config") - # Create validator with router for model validation - validator = PolicyValidator( - prisma_client=prisma_client, - llm_router=llm_router, - ) - # Initialize policies await init_policies( policies_config=policies_config,