diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index faccb613116..2c93aad820c 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -5544,7 +5544,9 @@ def _team_member_max_budget_alert_check( per_key_cfg=raw_config if isinstance(raw_config, Mapping) else None, ) alert_email_config: Final = { - pct: emails for pct, emails in (merged_config or {}).items() if pct.isdigit() and 1 <= int(pct) <= 100 + pct: emails + for pct, emails in (merged_config or {}).items() + if pct.isdigit() and len(pct) <= 3 and 1 <= int(pct) <= 100 } if not alert_email_config or spend <= 0: return diff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/test_litellm/proxy/auth/test_auth_checks.py index 184e96684ac..358ecaace36 100644 --- a/tests/test_litellm/proxy/auth/test_auth_checks.py +++ b/tests/test_litellm/proxy/auth/test_auth_checks.py @@ -1,5 +1,6 @@ import asyncio import json +import sys import time from collections.abc import Mapping from types import SimpleNamespace @@ -3399,7 +3400,14 @@ async def test_team_member_max_budget_alert_check_drops_thresholds_outside_1_to_ _team_member_max_budget_alert_check( team_id="team-1", team_alias="platform", - team_metadata={"team_member_max_budget_alert_emails": {"0": ["a@co.com"], "50": [], "150": ["b@co.com"]}}, + team_metadata={ + "team_member_max_budget_alert_emails": { + "0": ["a@co.com"], + "50": [], + "150": ["b@co.com"], + "1" * (sys.int_info.default_max_str_digits + 1): ["c@co.com"], + } + }, organization_id="org-1", user_id="user-1", user_email="member@co.com",