fix(telephony): scope link_existing_conversations rollback to a savepoint (review)

link_existing_conversations is the Contact after_insert hook; a full frappe.db.rollback() on a failed call_log.save() would discard the triggering Contact insert itself (and, in test mode, the whole unit of work). Savepoint the hook's DB work and roll back only to it.
This commit is contained in:
Mihir Kandoi
2026-06-30 12:17:39 +05:30
parent bd57e43446
commit a36065931d

View File

@@ -163,6 +163,7 @@ def link_existing_conversations(doc, state):
return
if doc.doctype != "Contact":
return
frappe.db.savepoint("link_call_logs")
try:
numbers = [d.phone for d in doc.phone_nos]
@@ -196,7 +197,7 @@ def link_existing_conversations(doc, state):
if not frappe.in_test:
frappe.db.commit()
except Exception:
frappe.db.rollback()
frappe.db.rollback(save_point="link_call_logs")
frappe.log_error(title=_("Error during caller information update"))