jkramer-ginkgo opened a new issue, #36957:
URL: https://github.com/apache/airflow/issues/36957

   ### Apache Airflow version
   
   2.8.1
   
   ### If "Other Airflow 2 version" selected, which one?
   
   2.8.0
   
   ### What happened?
   
   Seeing exceptions in code at:
   
   ```
   File 
"/opt/pyenv/versions/3.11.7/lib/python3.11/site-packages/airflow/sentry.py", 
line 127, in add_tagging
     task = task_instance.task
            ^^^^^^^^^^^^^^^^^^
   AttributeError: type object 'TaskInstance' has no attribute 'task'
   ```
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Have `sentry_on = True` and `schedule_after_task_execution = True`. Run a 
DAG that has tasks depending on other tasks. Scheduling of any downstream task 
will hit this bug.
   
   ### Operating System
   
   Linux (Ubuntu 22.04)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   I was able to attach a debugger and root cause this:
   
   [_schedule_downstream_tasks uses 
@Sentry.enrich_errors](https://github.com/apache/airflow/blob/2.8.0/airflow/models/taskinstance.py#L3222)
 which is [expecting to be 
decorating](https://github.com/apache/airflow/blob/2.8.0/airflow/sentry.py#L182-L185)
 a function that either has `self` as a `TaskInstance` or for `self` to have an 
attribute called `task_instance`. 
   
   A recent refactoring of this code broke this assumption. There are two paths 
forward to resolve as I see it:
   
   1. Update `enrich_errors` to look for `ti` in `kwargs`
   2. Remove `@Sentry.enrich_errors` from `_schedule_downstream_tasks`. I don't 
have the full context here, but I imagine the semantics of enriching errors for 
scheduling (as opposed to running tasks) doesn't make sense.
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to