Skip to content

Commit

Permalink
Do not try to render Slack Button with empty url in Signal message (#…
Browse files Browse the repository at this point in the history
…4099)

* Do not try to render Slack Button with empty url in Signal message

* Fix typo
  • Loading branch information
wssheldon authored Dec 15, 2023
1 parent 3add781 commit 5620fa5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/dispatch/plugins/dispatch_slack/case/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
+ [
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(),
Expand Down

0 comments on commit 5620fa5

Please sign in to comment.