potiuk 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_r370989926
 
 

 ##########
 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 saw it in a few tests, but one particularly that I could see it happening 
was:
   `pytest tests/task/task_runner/test_standard_task_runner.py  -s`
   
   You can run it in v1-10-test branch (commit 
ca0bbba19add1aef564c3379a9b8dfce55000cf1) to reproduce it. I have already 
applied this change with formatting while testing v1-10-test branch so it does 
not occur in the v1-10-test branch tip.
   
   I am now trying to fix all the flakiness and make v1-10-test stable and 
remove all the false information printed/flaky tests etc. so if you would like 
to spend quite some time and investigate it and make sure that it's fixed 
better - I am happy if you can help with this tasks. 
   
   Just to give you perspective - I had quite a lot to do to fix all the 
various test flakiness so I have no time to analyse all the path of 
TaskInstance printing and adding if's is the easiest one so I do not have think 
about this as well. So if you have time and can do it better I am more than 
happy. I assigned it to you then and maybe we can fix it together: 
https://issues.apache.org/jira/browse/AIRFLOW-6640 
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to