Skip to content

Commit

Permalink
#737 only collapse extra_msg_str if in the form of a list
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielwol committed Dec 21, 2023
1 parent fe771aa commit 383814c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dags/dag_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def task_fail_slack_alert(
# in case of a string (or the default empty string)
extra_msg_str = extra_msg

if isinstance(extra_msg_str, list):
#recursively collapse extra_msg_str's which are in the form of a list with new lines.
extra_msg_str = '\n'.join(
['\n'.join(item) if isinstance(item, list) else item for item in extra_msg_str]
)

# Slack failure message
if use_proxy:
# Temporarily accessing Airflow on Morbius through 8080 instead of Nginx
Expand Down Expand Up @@ -125,10 +131,7 @@ def task_fail_slack_alert(
slack_webhook_conn_id=SLACK_CONN_ID,
message=slack_msg,
username="airflow",
attachments=[
#recursively collapse extra_msg_str with new lines.
{"text": '\n'.join(['\n'.join(item) if isinstance(item, list) else item for item in extra_msg_str])}
],
attachments=[{"text": extra_msg_str}],
proxy=proxy,
)
return failed_alert.execute(context=context)

0 comments on commit 383814c

Please sign in to comment.