From 5787951ed1093b567e3b47816fb09e7ef8be2b87 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Thu, 18 Jun 2026 20:50:31 +0530 Subject: [PATCH] fix(crm): guard first_contact result before indexing (lead conversion time) Address review (#56105): the IS NOT NULL guard can return no rows (the count above filters on sender, this query on recipients), so [0][0] would raise IndexError. Fall back to None when empty, matching the prior behaviour for that case. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../crm/report/lead_conversion_time/lead_conversion_time.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py b/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py index ee0fc3e75d1..c16ea672f62 100644 --- a/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py +++ b/erpnext/crm/report/lead_conversion_time/lead_conversion_time.py @@ -130,7 +130,8 @@ def get_communication_details(filters): LIMIT 1 """, (d.contact_email), - )[0][0] + ) + first_contact = first_contact[0][0] if first_contact else None duration = flt(date_diff(invoice[0][0], first_contact))