From a31795056742daf91d94223bd93f2e7aa13bcea3 Mon Sep 17 00:00:00 2001 From: Abraham Kalungi Date: Wed, 18 Jun 2025 15:31:00 +0200 Subject: [PATCH] fix: prevent TypeError when concatenating first and last name in WhatsApp messages The last name on CRM Leads can be empty. In cases where it is, an error occurs: can only concatenate str (not "NoneType") to str. This prevents retrieving messages until a last name is added. --- crm/api/whatsapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crm/api/whatsapp.py b/crm/api/whatsapp.py index 2a6c698c..3e3889be 100644 --- a/crm/api/whatsapp.py +++ b/crm/api/whatsapp.py @@ -335,5 +335,5 @@ def get_from_name(message): else: from_name = doc.get("lead_name") else: - from_name = doc.get("first_name") + " " + doc.get("last_name") + from_name = " ".join(filter(None, [doc.get("first_name"), doc.get("last_name")])) return from_name