From 61b4c9067905dfdd3e4930fe040ab761379d135f Mon Sep 17 00:00:00 2001 From: Will Sheldon <114631109+wssheldon@users.noreply.github.com> Date: Fri, 8 Dec 2023 07:42:19 -0800 Subject: [PATCH 1/2] Do not try to render Slack Button with empty url in Signal message --- src/dispatch/plugins/dispatch_slack/case/messages.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dispatch/plugins/dispatch_slack/case/messages.py b/src/dispatch/plugins/dispatch_slack/case/messages.py index 9163f6d57644..06ccc46c876c 100644 --- a/src/dispatch/plugins/dispatch_slack/case/messages.py +++ b/src/dispatch/plugins/dispatch_slack/case/messages.py @@ -204,12 +204,20 @@ def create_signal_messages(case_id: int, channel_id: str, db_session: Session) - action_id=SignalNotificationActions.snooze, value=button_metadata, ), + ] + # The button URL must have at least one characters. + # Otherwise, Slack will raise a Validation error. + # external_url is not a required field. If it's empty, an empty list is added, + # which effectively doesn't add anything to the elements list. + + [ Button( text="Response Plan", action_id="button-link", url=first_instance_signal.external_url, - ), + ) ] + if first_instance_signal.external_url + else [] ), Section(text="*Alerts*"), Divider(), From fcbc0ee58a551746dafd14fdbb52ac7d316fec51 Mon Sep 17 00:00:00 2001 From: Will Sheldon <114631109+wssheldon@users.noreply.github.com> Date: Fri, 8 Dec 2023 07:42:52 -0800 Subject: [PATCH 2/2] Fix typo --- src/dispatch/plugins/dispatch_slack/case/messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/plugins/dispatch_slack/case/messages.py b/src/dispatch/plugins/dispatch_slack/case/messages.py index 06ccc46c876c..5af5f9512e50 100644 --- a/src/dispatch/plugins/dispatch_slack/case/messages.py +++ b/src/dispatch/plugins/dispatch_slack/case/messages.py @@ -205,7 +205,7 @@ def create_signal_messages(case_id: int, channel_id: str, db_session: Session) - value=button_metadata, ), ] - # The button URL must have at least one characters. + # The button URL must have at least one character. # Otherwise, Slack will raise a Validation error. # external_url is not a required field. If it's empty, an empty list is added, # which effectively doesn't add anything to the elements list.