Fixes mypy type error where router_model_names (a set) was incompatible
with List[str] parameter type.
Changed check_file_size_under_limit to accept Collection[str] instead of
List[str] since the parameter is only used for membership checks, making
it more flexible and avoiding unnecessary type conversions.
Resolves: proxy/proxy_server.py:5107 arg-type error
Update test_generate_model_id_with_deployment_model_name to accept the new
error message format that results from the list+join optimization.
The function still correctly rejects None values with a TypeError, but the
error message changed from 'unsupported operand type(s) for +=' to
'expected str instance, NoneType found' due to the implementation change
from string concatenation to list joining.
Replace string concatenation in loop with list append + join pattern.
This improves time complexity from O(n²) to O(n) and avoids creating
many temporary string objects during hash ID generation.
Replace copy.deepcopy() with dict.copy() in _get_all_deployments when
creating model aliases.
Safe because:
1. Only modifies top-level 'model_name' field (isolated by shallow copy)
2. Nested dicts (litellm_params, model_info) are never modified after return
3. When model_alias=None, returns original dict with NO copy, proving
callers expect nested structures to be read-only
4. Key insight: Code that needs to modify nested structures does deepcopy FIRST.
This proves the contract is: \"treat returned deployments as read-only for
nested fields.\" (see line 6894: copy.deepcopy before modifying litellm_params)
Performance: ~10-100x faster than deepcopy on nested dict structures.
Tests: All 114 router unit tests pass.
Add AST-based test to detect 'for ... in self.model_list' anti-pattern.
Enforces use of index maps (model_id_to_deployment_index_map and
model_name_to_deployment_indices) for O(1) lookups instead of O(n) iteration.
- Use model_id_to_deployment_index_map and model_name_to_deployment_indices for O(1) lookups in get_model_info, get_deployment_by_model_group_name, and get_model_ids
Fixes mypy type error where router_model_names (a set) was incompatible
with List[str] parameter type.
Changed check_file_size_under_limit to accept Collection[str] instead of
List[str] since the parameter is only used for membership checks, making
it more flexible and avoiding unnecessary type conversions.
Resolves: proxy/proxy_server.py:5107 arg-type error
Add AST-based test to detect 'for ... in self.model_list' anti-pattern.
Enforces use of index maps (model_id_to_deployment_index_map and
model_name_to_deployment_indices) for O(1) lookups instead of O(n) iteration.
- Keep only 2 focused tests: single role extraction and no roles claim
- Remove complex fixtures and edge case tests
- Maintain clean, maintainable test coverage
- Fix get_app_roles_from_id_token to use 'app_roles' claim instead of 'roles'
- Add comprehensive unit tests for EntraID app roles functionality
- Prevent regressions in Microsoft EntraID SSO authentication
Resolves issue where EntraID app roles were not being extracted correctly
from JWT tokens, causing authentication failures for users with assigned
app roles in Microsoft EntraID.