mik-laj commented on a change in pull request #7257: [AIRFLOW-6636] Avoid 
exceptions when printing task instance
URL: https://github.com/apache/airflow/pull/7257#discussion_r370930282
 
 

 ##########
 File path: airflow/models/taskinstance.py
 ##########
 @@ -1137,18 +1143,30 @@ def handle_failure(self, error, test_mode=None, 
context=None, session=None):
                         'dag_id=%s, task_id=%s, execution_date=%s, 
start_date=%s, end_date=%s',
                         self.dag_id,
                         self.task_id,
-                        self.execution_date.strftime('%Y%m%dT%H%M%S'),
-                        self.start_date.strftime('%Y%m%dT%H%M%S'),
-                        self.end_date.strftime('%Y%m%dT%H%M%S'))
+                        self.execution_date.strftime('%Y%m%dT%H%M%S') if 
hasattr(
+                            self,
+                            'execution_date') and self.execution_date else '',
+                        self.start_date.strftime('%Y%m%dT%H%M%S') if hasattr(
+                            self,
+                            'start_date') and self.start_date else '',
+                        self.end_date.strftime('%Y%m%dT%H%M%S') if hasattr(
 
 Review comment:
   I think this attribute should always be created. If it is not needed, it 
should have an empty value. It is better to solve the problem of missing 
attributes than to hide the problem. All attributes, that the class has, should 
be created in the __init__ method.
   ```
   self.start_date.strftime('%Y%m%dT%H%M%S') if self.start_date else None,
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to