tirkarthi opened a new issue, #22933:
URL: https://github.com/apache/airflow/issues/22933

   ### Apache Airflow version
   
   2.2.5 (latest released)
   
   ### What happened
   
   Task duration page crashes when there is a failed task in the list of task 
instances. This happens since the chart calculates duration and accesses 
`execution_date` on `TaskFail` instances which don't exist. The query should be 
modified such that relevant `TaskInstance` execution_date field should be used 
based on matching run_id between `TaskInstance` and `TaskFail`.
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   1. Create a dag that fails.
   2. After an execution visit the task duration page.
   
   ```python
   import datetime
   
   from airflow import DAG
   from airflow.operators.bash import BashOperator
   
   with DAG(
       "raise_exception_1",
       description="DAG that cuases failure",
       tags=["example-failure"],
       catchup=False,
       start_date=datetime.datetime(2022, 3, 28),
       default_args={
           "depends_on_past": False,
           "email": ["airf...@example.com"],
           "email_on_failure": False,
           "email_on_retry": False,
           "retries": 0,
       },
   ) as dag:
       t1 = BashOperator(task_id="sleep_5", bash_command="sleep 5 && invalid")
       t1 = BashOperator(task_id="sleep_10", bash_command="sleep 10")
   ```
   
   ```python
   Python version: 3.10.4
   Airflow version: 2.3.0.dev0
   Node: laptop
   
-------------------------------------------------------------------------------
   Traceback (most recent call last):
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py",
 line 2447, in wsgi_app
       response = self.full_dispatch_request()
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py",
 line 1952, in full_dispatch_request
       rv = self.handle_user_exception(e)
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py",
 line 1821, in handle_user_exception
       reraise(exc_type, exc_value, tb)
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/_compat.py",
 line 39, in reraise
       raise value
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py",
 line 1950, in full_dispatch_request
       rv = self.dispatch_request()
     File 
"/home/karthikeyan/stuff/python/airflow/.env/lib/python3.10/site-packages/flask/app.py",
 line 1936, in dispatch_request
       return self.view_functions[rule.endpoint](**req.view_args)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/auth.py", line 
40, in decorated
       return func(*args, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/decorators.py", 
line 80, in wrapper
       return f(*args, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/utils/session.py", 
line 71, in wrapper
       return func(*args, session=session, **kwargs)
     File "/home/karthikeyan/stuff/python/airflow/airflow/www/views.py", line 
2911, in duration
       failed_task_instance.execution_date,
   AttributeError: 'TaskFail' object has no attribute 'execution_date'
   ```
   
   ### Operating System
   
   Ubuntu 20.04
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Virtualenv installation
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] 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-unsubscr...@airflow.apache.org.apache.org

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

Reply via email to