From 820c3dae29065a063f764d8ff53d1ff4ef7a34a3 Mon Sep 17 00:00:00 2001 From: David Whittaker <84562015+whitdog47@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:13:46 -0800 Subject: [PATCH] fix(case): log warning instead of throw exception (#5604) --- src/dispatch/case/messaging.py | 6 +++--- src/dispatch/conversation/flows.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/dispatch/case/messaging.py b/src/dispatch/case/messaging.py index 02143f19ff2e..fa07b09fb118 100644 --- a/src/dispatch/case/messaging.py +++ b/src/dispatch/case/messaging.py @@ -341,9 +341,9 @@ def send_case_welcome_participant_message( "assignee_fullname": case.assignee.individual.name, "assignee_team": case.assignee.team, "assignee_weblink": case.assignee.individual.weblink, - "reporter_fullname": case.reporter.individual.name, - "reporter_team": case.reporter.team, - "reporter_weblink": case.reporter.individual.weblink, + "reporter_fullname": case.reporter.individual.name if case.reporter else None, + "reporter_team": case.reporter.team if case.reporter else None, + "reporter_weblink": case.reporter.individual.weblink if case.reporter else None, "document_weblink": resolve_attr(case, "case_document.weblink"), "storage_weblink": resolve_attr(case, "storage.weblink"), "ticket_weblink": resolve_attr(case, "ticket.weblink"), diff --git a/src/dispatch/conversation/flows.py b/src/dispatch/conversation/flows.py index a9dd5689ef97..50a4cce4d29d 100644 --- a/src/dispatch/conversation/flows.py +++ b/src/dispatch/conversation/flows.py @@ -49,9 +49,15 @@ def create_case_conversation( # Do not overwrite a case conversation with one of the same type (thread, channel) if case.conversation: if case.has_channel: - raise RuntimeError("Case already has a dedicated channel conversation.") + log.warning( + f"Trying to create case conversation but case {case.id} already has a dedicated channel conversation." + ) + return if case.has_thread and not case.dedicated_channel: - raise RuntimeError("Case already has a thread conversation.") + log.warning( + "Trying to create case conversation but case {case.id} already has a thread conversation." + ) + return # This case is a thread version, we send a new messaged (threaded) to the conversation target # for the configured case type