You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "SakshamSinghal20 (via GitHub)" <gi...@apache.org> on 2026/02/20 14:10:38 UTC
[PR] fix: add null checks for dag_version access in scheduler [airflow]
SakshamSinghal20 opened a new pull request, #62225:
URL: https://github.com/apache/airflow/pull/62225
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #62198
* related: #62198
-->
### Fix Scheduler Crash on Nullable [dag_version](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/tests/unit/jobs/test_scheduler_job.py:2811:4-2838:52) Access
Fixes #62198
The `TaskInstance.dag_version` field is nullable in the data model (specifically for tasks migrated from Airflow 2 to Airflow 3). However, several locations in the [SchedulerJobRunner](cci:2://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py:218:0-3259:105) accessed `ti.dag_version.bundle_name` and `ti.dag_version.bundle_version` without null checks, leading to `AttributeError: 'NoneType' object has no attribute 'bundle_name'` and crashing the scheduler.
This PR adds null checks to three critical locations in [scheduler_job_runner.py](cci:7://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py:0:0-0:0):
1. **Task Callback Execution**: In [process_executor_events](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py:1022:4-1276:32), when an executor reports a task failure/retry that requires a callback.
2. **Email Notifications**: In [process_executor_events](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py:1022:4-1276:32), when a task failure triggers an email.
3. **Stuck-in-Queued Handling**: In [_maybe_requeue_stuck_ti](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/src/airflow/jobs/scheduler_job_runner.py:2516:4-2587:37), when a task that has exceeded requeue attempts is marked as failed and requires a callback.
**Approach**:
When [dag_version](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/tests/unit/jobs/test_scheduler_job.py:2811:4-2838:52) is [None](cci:1://file:///c:/Users/Saksham%20Singhal/OneDrive/Desktop/Airflowww/airflow/airflow-core/tests/unit/jobs/test_scheduler_job.py:2281:4-2306:47), the scheduler now logs a warning and skips the callback/email request, rather than crashing. This mirrors the existing defensive pattern already implemented in the heartbeat timeout handler.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (just for guidence and logic)
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add null checks for dag_version access in scheduler [airflow]
Posted by "SakshamSinghal20 (via GitHub)" <gi...@apache.org>.
SakshamSinghal20 commented on PR #62225:
URL: https://github.com/apache/airflow/pull/62225#issuecomment-3946577648
Great catch, @SameerMesiah97! You were spot on about the implicit semantics dropping those alerts for legacy DAGs would have been a bad side effect. I've just pushed a new commit that fixes this. Instead of skipping the requests, the logic now safely falls back so that TaskCallbackRequest and EmailCallbackRequest are still triggered even when ti.dag_version is None.
I also added the parameterized unit tests you suggested. They explicitly verify that the executor successfully sends the callback requests in both scenarios (when dag_version is present and when it is None).
Let me know if the updated approach looks good to you!
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add null checks for dag_version access in scheduler [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #62225:
URL: https://github.com/apache/airflow/pull/62225
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add null checks for dag_version access in scheduler [airflow]
Posted by "SakshamSinghal20 (via GitHub)" <gi...@apache.org>.
SakshamSinghal20 commented on PR #62225:
URL: https://github.com/apache/airflow/pull/62225#issuecomment-3960022999
@SameerMesiah97 could you please review it again whenever you get time?
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org