ayanhussain81 opened a new pull request, #72370:
URL: https://github.com/apache/airflow/pull/72370
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
PR #66485 fixed scheduler-emitted `TaskCallbackRequest`s (external kill,
heartbeat
timeout, stuck-in-queued) to source `bundle_version` from
`dag_run.bundle_version`
instead of `DagVersion.bundle_version`, so that callbacks for Dags with
`disable_bundle_versioning=True` stay unpinned and run against the same
on-disk
code the task did, instead of pinning to a version the run was never pinned
to.
That fix touched three call sites but missed a fourth: the `EmailRequest`
built a
few lines below the `TaskCallbackRequest` in `process_executor_events`'s
external-kill path. It still falls back to `DagVersion.bundle_version`
whenever
`dag_version` is set, regardless of whether `dag_run.bundle_version` is
`None`.
For a Dag with `disable_bundle_versioning=True` and `email_on_failure`/
`email_on_retry` configured, when a task is detected as externally killed,
the
failure/retry email ends up pinned to a stale bundle version the run was
never
pinned to — causing the Dag Processor to check out an unnecessary
`versions/<sha>/` working tree for that email callback (the exact class of
problem #66485 set out to fix, just through the one path it didn't touch).
This applies the same guard used at the other three call sites (and used by
the
`_resolve_ti_callback_bundle_info` helper, whose own docstring says
`process_executor_events` "inlines the same resolution" — this brings it
back in
sync), and adds a regression test mirroring the existing
`test_external_kill_callback_bundle_version_follows_dag_run` for the
`EmailRequest`
path, since the existing `TestSchedulerCallbackBundleInfoDagVersionNullable`
suite
verifies a reimplementation of the logic rather than the real per-callsite
code,
which is how this one diverged unnoticed.
Verified locally: the new test fails against the pre-fix code
(`AssertionError: -'abc123-sha' +None`) and passes with the fix; the full
`bundle_version` / `process_executor_events` / heartbeat-timeout test
surface in
`test_scheduler_job.py` passes with no regressions; `ruff check` and
`ruff format --check` are clean on both changed files.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
<!--
Generated-by: Claude Code following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
Claude Code was used to investigate the root cause (via `git blame`/`git
log` on the
original fix, and tracing `EmailRequest.bundle_version` through to
`BundleVersionLock`), implement the fix, write the regression test, and
run/verify
the test suite. All findings and the diff were reviewed and understood before
submission.
---
* Read the [Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines).
* No related issue — this was found via source/history review rather than a
bug report.
* Newsfragment (`{pr_number}.bugfix.rst`) will be added as a follow-up
commit once this PR's number is known.
--
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]