dstandish commented on a change in pull request #12910:
URL: https://github.com/apache/airflow/pull/12910#discussion_r538846319



##########
File path: airflow/models/taskinstance.py
##########
@@ -773,7 +773,7 @@ def get_previous_start_date(
         """
         self.log.debug("previous_start_date was called")
         prev_ti = self.get_previous_ti(state=state, session=session)
-        return prev_ti and prev_ti.start_date
+        return prev_ti and prev_ti.start_date and 
pendulum.instance(prev_ti.start_date)

Review comment:
       @kaxil please see previous comment for reasoning on this change.   the 
issue is in test cases (for python virtualenv operator) there is no dag run, 
due to test design.  in this situation (when previous_ti is called on a TI with 
no dag run), airflow's behavior is not to attempt to retrieve a "previous" task 
instance but instead to create a _new_ TI with the execution date of the prev 
schedule.  
   
   importantly, a brand new TI such as this has no start_date.  so we must 
check not only for prev_ti but also that this ti has a start date
   
   to fix this, we'd have to add a dag run in these two virtualenv operator 
tests  -- or something like that
   
   but perhaps there is reason why we are testing with no dag run -- i don't 
know




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


Reply via email to