You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/15 13:21:57 UTC
[GitHub] [airflow] gfelot opened a new issue #9308: Cannot send args in email body
gfelot opened a new issue #9308:
URL: https://github.com/apache/airflow/issues/9308
**Apache Airflow version**:
1.10.9
**Environment**:
GCE - Debian 10
**What happened**:
Try to send an email on failure success. Unfortunately the body args in the function `send_email_smtp` doesn't seem to get the arg of my f-string.
If I put the exact same variable in the title and body of the email I got the title right and not the body.
I cannot do my alerting as planned because of this
Test DAG
```
from datetime import datetime
from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
from airflow.utils.email import send_email_smtp
default_args = {
"owner": "lisea-mesea",
"depends_on_past": False,
"start_date": datetime(2020, 6, 15),
}
def notify_email(contextDict, **kwargs):
"""Send custom email alerts."""
# email title.
title = f"Airflow alert: {contextDict['dag']} Failed"
# email contents
body = "Fail in DAG {} for task {}".format(contextDict['dag'], contextDict['task'])
print(body)
send_email_smtp(
["my@email.com"], title, body)
def print_fail():
print("Hello !")
exit(1)
with DAG(
"test_email", # ICI
default_args=default_args,
schedule_interval=None
) as dag:
preprocessing_started = DummyOperator(
task_id="go_email_go"
)
python_fail = PythonOperator(
task_id="pyhton_def",
python_callable=print_fail,
on_failure_callback=notify_email,
email_on_failure=False
)
preprocessing_started >> python_fail
```
**What you expected to happen**:
I exepect to have a mail like
```
TITLE : Airflow alert: <DAG: test_email> Failed
BODY : Fail in DAG <DAG: test_email> for task <Task(PythonOperator): pyhton_def>
```
And I got
```
TITLE : Airflow alert: <DAG: test_email> Failed
BODY : Fail in DAG for task
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] gfelot closed issue #9308: Cannot send args in email body
Posted by GitBox <gi...@apache.org>.
gfelot closed issue #9308:
URL: https://github.com/apache/airflow/issues/9308
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #9308: Cannot send args in email body
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #9308:
URL: https://github.com/apache/airflow/issues/9308#issuecomment-644131462
Thanks for opening your first issue here! Be sure to follow the issue template!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org