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

   ### Apache Airflow version
   
   Other Airflow 3 version (please specify below)
   
   ### If "Other Airflow 3 version" selected, which one?
   
   3.0.6
   
   ### What happened?
   
   The `dag_version` field of `TaskInstance` is nullable. 
   
https://github.com/apache/airflow/blob/3.0.6/airflow-core/src/airflow/api_fastapi/core_api/datamodels/task_instances.py#L78
   However, some code exists that accesses fields within dag_version, such as 
`ti.dag_version.bundle_name`, without performing a null check on dag_version.
   
https://github.com/apache/airflow/blob/3.0.6/airflow-core/src/airflow/jobs/scheduler_job_runner.py#L971-L972
   Normally, it seems unproblematic, but it occurs under specific conditions 
(e.g., retry_callback, failure_callback) and is killing the scheduler.
   ``` python
   [2026-02-13T09:46:35.866+0000] {scheduler_job_runner.py:1052} ERROR - 
Exception when executing SchedulerJob._run_scheduler_loop
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py",
 line 1048, in _execute
       self._run_scheduler_loop()
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py",
 line 1345, in _run_scheduler_loop
       num_finished_events += self._process_executor_events(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py",
 line 808, in _process_executor_events
       return SchedulerJobRunner.process_executor_events(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py",
 line 971, in process_executor_events
       bundle_name=ti.dag_version.bundle_name,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
   AttributeError: 'NoneType' object has no attribute 'bundle_name'
   ```
   
   ### What you think should happen instead?
   
   When accessing something like `ti.dag_version.bundle_name`, it seems 
necessary to add a check for `dag_version` 
   ``` python
   None if ti.dag_version else ti.dag_version.bundle_name
   ```
   or override a function like `__getattribute__` so that if `dag_version` is 
null, the subfield also returns null.
   
   ### How to reproduce
   
   1. Run task with airflow 2 (dag_version = None)
   2. Upgrade to airflow 3
   3. Re-run task in step 1 (this task need to be fail and have some callbacks)
   
   
   ### Operating System
   
   Debian GNU/Linux 12 (bookworm)
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==9.12.0
   apache-airflow-providers-celery==3.12.2
   apache-airflow-providers-cncf-kubernetes==10.7.0
   apache-airflow-providers-common-compat==1.13.1
   apache-airflow-providers-common-io==1.6.2
   apache-airflow-providers-common-messaging==1.0.5
   apache-airflow-providers-common-sql==1.27.5
   apache-airflow-providers-docker==4.4.2
   apache-airflow-providers-elasticsearch==6.3.2
   apache-airflow-providers-fab==2.4.1
   apache-airflow-providers-ftp==3.13.2
   apache-airflow-providers-git==0.0.6
   apache-airflow-providers-google==17.1.0
   apache-airflow-providers-grpc==3.8.2
   apache-airflow-providers-hashicorp==4.3.2
   apache-airflow-providers-http==5.3.3
   apache-airflow-providers-microsoft-azure==12.6.1
   apache-airflow-providers-mysql==6.3.3
   apache-airflow-providers-odbc==4.10.2
   apache-airflow-providers-openlineage==2.6.1
   apache-airflow-providers-postgres==6.2.3
   apache-airflow-providers-redis==4.2.0
   apache-airflow-providers-sendgrid==4.1.3
   apache-airflow-providers-sftp==5.3.4
   apache-airflow-providers-slack==9.1.4
   apache-airflow-providers-smtp==2.2.0
   apache-airflow-providers-snowflake==6.4.0
   apache-airflow-providers-ssh==4.1.3
   apache-airflow-providers-standard==1.10.1
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] 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