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 2022/07/08 11:07:02 UTC

[GitHub] [airflow] ecodina opened a new issue, #24919: Send default email if file "html_content_template" not found

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: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on issue #24919: Send default email if file "html_content_template" not found

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #24919:
URL: https://github.com/apache/airflow/issues/24919#issuecomment-1179378522

   Just follow https://github.com/apache/airflow/blob/main/CONTRIBUTORS_QUICK_START.rst


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk closed issue #24919: Send default email if file "html_content_template" not found

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #24919: Send default email if file "html_content_template" not found
URL: https://github.com/apache/airflow/issues/24919


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] ecodina commented on issue #24919: Send default email if file "html_content_template" not found

Posted by GitBox <gi...@apache.org>.
ecodina commented on issue #24919:
URL: https://github.com/apache/airflow/issues/24919#issuecomment-1179084171

   Hi @potiuk 
   
   I have never created a PR on such a complex project. However, since this seems easy to fix, it should prove useful to learn! I'll create the PR during the following week.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on issue #24919: Send default email if file "html_content_template" not found

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #24919:
URL: https://github.com/apache/airflow/issues/24919#issuecomment-1178969282

   You seem to know how to fix it, would you like to make a PR fixing it? Otherwise it will have to wait for someone who would likel to pick it.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] ecodina commented on issue #24919: Send default email if file "html_content_template" not found

Posted by GitBox <gi...@apache.org>.
ecodina commented on issue #24919:
URL: https://github.com/apache/airflow/issues/24919#issuecomment-1179608686

   I have just created PR #24943 which should fix this issue.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org