From 16f17829b619949e933c45588d6f072e8e95fb93 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 1 Mar 2025 15:44:52 -0800 Subject: [PATCH] Fix: handle null workflow body and email subject (#9271) --- src/documents/signals/handlers.py | 54 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index 78d0043b5..1fd34dd81 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -1002,29 +1002,37 @@ def run_workflows( added = timezone.localtime(timezone.now()) created = timezone.localtime(overrides.created) - subject = parse_w_workflow_placeholders( - action.email.subject, - correspondent, - document_type, - owner_username, - added, - filename, - current_filename, - created, - title, - doc_url, + subject = ( + parse_w_workflow_placeholders( + action.email.subject, + correspondent, + document_type, + owner_username, + added, + filename, + current_filename, + created, + title, + doc_url, + ) + if action.email.subject + else "" ) - body = parse_w_workflow_placeholders( - action.email.body, - correspondent, - document_type, - owner_username, - added, - filename, - current_filename, - created, - title, - doc_url, + body = ( + parse_w_workflow_placeholders( + action.email.body, + correspondent, + document_type, + owner_username, + added, + filename, + current_filename, + created, + title, + doc_url, + ) + if action.email.body + else "" ) try: n_messages = send_email( @@ -1105,7 +1113,7 @@ def run_workflows( f"Error occurred parsing webhook params: {e}", extra={"group": logging_group}, ) - else: + elif action.webhook.body: data = parse_w_workflow_placeholders( action.webhook.body, correspondent,