Add Jinja template rendering for deadline callback kwargs#68408
Draft
seanghaeli wants to merge 4 commits into
Draft
Add Jinja template rendering for deadline callback kwargs#68408seanghaeli wants to merge 4 commits into
seanghaeli wants to merge 4 commits into
Conversation
added 4 commits
June 9, 2026 20:55
When a deadline callback fires, it now fetches DagRun context from the
Execution API and passes it to the callback as context["deadline"] and
context["dag_run"]. This enables Jinja template rendering ({{ dag_run }},
{{ deadline.deadline_time }}) and enriched notifications.
Key changes:
- Add GetDagRun comms message and handler in callback supervisor
- Wire dag_id/run_id/deadline_id/deadline_time through the workload path
- Build context dict from DagRun response via build_context_from_dag_run
- Fail callback (for retry) when context fetch fails instead of running
degraded
- Restrict token:workload to read-only Execution API routes (GET only)
- Add hash verification in _ensure_bundle_module_registered to prevent
wrong-bundle loading when multiple bundles share a filename
- Run bundle initialization off triggerer event loop (asyncio.to_thread)
- Extract _load_mangled_module to airflow._shared.module_loading as a
shared helper for both triggerer and executor paths
Plain function callbacks can now use Jinja2 templates in their kwargs:
callback_kwargs={"text": "DAG {{ dag_run.dag_id }} missed at {{ deadline.deadline_time }}"}
String values containing `{{` are rendered against the callback context
(which includes dag_run, deadline, run_id, ds, ts, etc.) 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.
Notifier classes (BaseNotifier subclasses) are unaffected — they handle
their own rendering via __call__.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-on to #66608 (when that's merged this will be 25 line PR, just wanted to have it up now). 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.
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.contextkey itself, and strings without template markers pass through unchanged.BaseNotifiersubclasses) are unaffected; they handle their own rendering via__call__.Testing
"Deadline {{ deadline.deadline_time }} missed for {{ dag_run.dag_id }}"rendered to real values through a live triggerer + scheduler run.