You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "1fanwang (via GitHub)" <gi...@apache.org> on 2026/07/23 23:17:38 UTC

[PR] Add HITLOperator subject/body to summary after rendering [airflow]

1fanwang opened a new pull request, #70345:
URL: https://github.com/apache/airflow/pull/70345

   `subject` and `body` are template fields, so they are rendered after `__init__` runs. The constructor built `hitl_summary` with `self.subject`/`self.body`, so a templated `subject` or `body` was captured in the summary as its un-rendered Jinja expression. Build the base summary in `__init__` without them and add their rendered values from `execute()` and `execute_complete()` (both run after rendering) via a shared helper, so listeners see the resolved `subject`/`body`.
   
   Behaviour change worth a maintainer's eye: `hitl_summary` no longer carries `subject`/`body` immediately after `__init__` — they appear once `execute()` runs. The prior values there were the un-rendered expressions, so anything reading the summary before the task runs was already getting placeholder text; now it gets nothing until execute, then the rendered value. The subclasses (`ApprovalOperator`, `HITLBranchOperator`, `HITLEntryOperator`) that extend the summary in their own `__init__`/`execute_complete` still work, since `execute_complete` calls `super()`.
   
   related: #70296
   
   <details><summary>Testing Done</summary>
   
   New `test_execute_populates_rendered_subject_body` templates `subject`/`body`, renders, runs `execute()`, and asserts the summary holds the rendered values (and that they are absent right after `__init__`). It fails on the pre-fix source (the summary carried the un-rendered `{{ ds }}` from `__init__`) and passes after. The lifecycle tests in `TestHITLSummaryForListeners` were updated so the `__init__`-stage assertions no longer expect `subject`/`body`, while the execute / execute_complete stages still assert them. `test_hitl.py`: 81 passed, 1 skipped. `validate_operators_init.py` on the operator exits 0.
   
   </details>
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: GitHub Copilot CLI 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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Read HITLOperator subject/body into the summary lazily [airflow]

Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 merged PR #70345:
URL: https://github.com/apache/airflow/pull/70345


-- 
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