uranusjr commented on code in PR #24943:
URL: https://github.com/apache/airflow/pull/24943#discussion_r918795507
##########
airflow/models/taskinstance.py:
##########
@@ -2271,8 +2271,13 @@ def get_email_subject_content(
def render(key: str, content: str) -> str:
if conf.has_option('email', key):
path = conf.get_mandatory_value('email', key)
- with open(path) as f:
- content = f.read()
+ try:
+ with open(path) as f:
+ content = f.read()
+ except FileNotFoundError:
+ self.log.warning(f"Could not find email template file
'{path}'. Using defaults...")
+ except:
Review Comment:
-1 to this blank catch. It’s probably worthwhile to catch all OSError, but
this is way to broad.
##########
airflow/models/taskinstance.py:
##########
@@ -2271,8 +2271,13 @@ def get_email_subject_content(
def render(key: str, content: str) -> str:
if conf.has_option('email', key):
path = conf.get_mandatory_value('email', key)
- with open(path) as f:
- content = f.read()
+ try:
+ with open(path) as f:
+ content = f.read()
+ except FileNotFoundError:
+ self.log.warning(f"Could not find email template file
'{path}'. Using defaults...")
Review Comment:
Better to use `{path!r}`
--
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]