From 0a4b02fe76b30e1265833d4da4dd289a35b5c493 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Sat, 18 Apr 2026 14:07:18 -0700 Subject: [PATCH] fix: tighten recipient_emails guard to reject empty list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit send_max_budget_alert_email previously guarded with `is not None`, which accepts `[]` and then crashes on `recipient_emails[0]` inside _get_email_params. The current caller (_handle_multi_threshold_max_budget_alert) already filters empty lists upstream, but the public method signature makes no such guarantee — a future caller passing [] would hit IndexError. Switch to truthiness so both None and [] fall through to the single-recipient path. --- .../enterprise_callbacks/send_emails/base_email.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py b/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py index d3c8b51a5a..89c3b85468 100644 --- a/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py +++ b/enterprise/litellm_enterprise/enterprise_callbacks/send_emails/base_email.py @@ -359,7 +359,7 @@ class BaseEmailLogger(CustomLogger): else "N/A" ) - if recipient_emails is not None: + if recipient_emails: # Multi-threshold path: batch send with generic key-based greeting email_params = await self._get_email_params( email_event=EmailEvent.max_budget_alert,