ecodina opened a new issue, #24919:
URL: https://github.com/apache/airflow/issues/24919

   ### Apache Airflow version
   
   2.3.2 (latest released)
   
   ### What happened
   
   I created a new email template to be sent when there are task failures. I 
accidentally added the path to the `[email] html_content_template` and `[email] 
subject_template` with a typo and no email was sent. The task's log is the 
following:
   
   ```
   Traceback (most recent call last):
     File 
"/home/user/.conda/envs/airflow/lib/python3.9/site-packages/airflow/models/taskinstance.py",
 line 1942, in handle_failure
       self.email_alert(error, task)
     File 
"/home/user/.conda/envs/airflow/lib/python3.9/site-packages/airflow/models/taskinstance.py",
 line 2323, in email_alert
       subject, html_content, html_content_err = 
self.get_email_subject_content(exception, task=task)
     File 
"/home/user/.conda/envs/airflow/lib/python3.9/site-packages/airflow/models/taskinstance.py",
 line 2315, in get_email_subject_content
       subject = render('subject_template', default_subject)
     File 
"/home/user/.conda/envs/airflow/lib/python3.9/site-packages/airflow/models/taskinstance.py",
 line 2311, in render
       with open(path) as f:
   FileNotFoundError: [Errno 2] No such file or directory: 
'/home/user/airflow/config/templates/email_failure_subject.tmpl'
   ```
   
   I've looked the TaskInstance class 
(https://github.com/apache/airflow/blob/main/airflow/models/taskinstance.py).
   
   I've seen that the `render` function 
(https://github.com/apache/airflow/blob/bcf2c418d261c6244e60e4c2d5de42b23b714bd1/airflow/models/taskinstance.py#L2271)
 has a `content` parameter, which is not used inside.
   
   I guess the solution to this bug is simple: just add a `try - catch` block 
and return the default content in the `catch` part.
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   _No response_
   
   ### Operating System
   
   CentOS Linux 8
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   Conda environment
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to