seanghaeli opened a new pull request, #68408:
URL: https://github.com/apache/airflow/pull/68408
## Summary
Follow-on to #66608. Now that deadline callbacks receive a full context at
runtime, render Jinja templates in the callback's string kwargs against that
context before invoking the callback.
```python
DeadlineAlert(
...,
callback=SyncCallback(notify),
callback_kwargs={"text": "DAG {{ dag_run.dag_id }} missed at {{
deadline.deadline_time }}"},
)
```
> **Draft / stacked on #66608.** This builds on the runtime-context fetch in
#66608; until that merges, the diff here includes #66608's commits. The
Jinja-specific change is just 2 files (`callback_supervisor.py` +25, test +83).
Will rebase to a clean diff once #66608 lands.
## What
- `_render_callback_kwargs()` renders string kwargs containing `{{` against
the callback context (`dag_run`, `deadline`, `run_id`, `ds`, `ts`, etc.) just
before the callback is invoked.
- Non-string values, the `context` key itself, and strings without template
markers pass through unchanged.
- Render failures fall back to the raw string with a warning — a bad
template never crashes the callback.
- Notifier classes (`BaseNotifier` subclasses) are unaffected; they handle
their own rendering via `__call__`.
## Why
Second half of the [WORKLOADS] template-rendering task. #66608 delivered the
runtime context; this delivers the rendering that consumes it, replacing the
closed #64984 which predated runtime context fetching.
## Testing
- 6 unit tests: single template, multiple kwargs, non-string skip, no-marker
skip, deadline context resolution, graceful fallback on invalid template (all
passing).
- Verified end-to-end in Breeze: `"Deadline {{ deadline.deadline_time }}
missed for {{ dag_run.dag_id }}"` rendered to real values through a live
triggerer + scheduler run.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 4.8)
Generated-by: Claude Code (Opus 4.8) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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]