You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "pierrejeambrun (via GitHub)" <gi...@apache.org> on 2026/05/28 10:21:43 UTC

[PR] Apply note in one shot when clearing a Dag Run / task instances [airflow]

pierrejeambrun opened a new pull request, #67639:
URL: https://github.com/apache/airflow/pull/67639

   **Stacked on top of #67564 — only the second commit (\`Apply note in one shot...\`) is in this PR's scope; the first commit will disappear once #67564 merges.**
   
   Today the Clear dialogs (single-run and bulk, both for Dag Runs and
   Task Instances) issue two requests on confirm: first ``POST .../clear``
   to actually clear, then a follow-up ``PATCH .../dagRuns/{run_id}`` /
   ``PATCH .../taskInstances/...`` to attach the note the user typed in
   the dialog. The two calls race (the note can land before the clear
   finishes invalidating queries) and the second one's failure can leave
   a cleared run/TI with a stale note.
   
   ## Summary
   
   - **Backend:** ``DAGRunClearBody`` gains a ``note: str | None`` field
     (max length 1000). After the clear succeeds in ``clear_dag_run``,
     if ``note`` is set we apply it to the cleared run with the same
     ``dag_run.note = (text, user_id)`` / ``dag_run_note.content = …``
     shape that ``patch_dag_run`` already uses.
   
     ``ClearTaskInstancesBody`` already carries this field and already
     applies it via ``_patch_task_instance_note`` in the same
     transaction — that side is unchanged.
   
   - **Semantics** mirror the bulk-update / patch convention:
     - ``note=None`` (the default, or omitted entirely) → leave the
       existing note untouched.
     - any string value (including ``""``) → replace the existing note
       with that value.
     - dry-run never writes.
   
   - **UI:** ``ClearRunDialog``, ``ClearTaskInstanceDialog`` and
     ``useBulkClearDagRuns`` pass ``note`` directly in the clear body
     (only when it changed) and drop their secondary ``patchDagRun`` /
     ``patchTaskInstance`` calls. Bulk clear of TIs already followed
     this pattern.
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.7)
   
   Generated-by: Claude Code (Opus 4.7) 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] Apply note when clearing a Dag Run / task instances [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #67639:
URL: https://github.com/apache/airflow/pull/67639#discussion_r3325438752


##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx:
##########
@@ -264,21 +256,13 @@ const ClearTaskInstanceDialog = (props: Props) => {
                 include_future: future,
                 include_past: past,
                 include_upstream: upstream,
+                note: noteChanged ? note : undefined,

Review Comment:
   That's a good point. I believe this behavior is intended. (All TI displayed should have the not set, it's easier to comprehend the downstream deps were cleared cause the note says so, and you don't have to look in the parent tasks to check for a clearing note)



-- 
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] Apply note when clearing a Dag Run / task instances [airflow]

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


-- 
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] Apply note when clearing a Dag Run / task instances [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #67639:
URL: https://github.com/apache/airflow/pull/67639#discussion_r3325416750


##########
airflow-core/src/airflow/ui/src/queries/useBulkClearDagRuns.ts:
##########
@@ -106,6 +106,7 @@ export const useBulkClearDagRuns = ({ deselectKeys, onSuccessConfirm }: Props) =
           dagRunId: dagRun.dag_run_id,
           requestBody: {
             dry_run: false,
+            note: options.note ?? undefined,

Review Comment:
   Invalid, that's the whole point of this PR. Prevent a second call for setting the note only.



-- 
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] Apply note when clearing a Dag Run / task instances [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #67639:
URL: https://github.com/apache/airflow/pull/67639#discussion_r3325450730


##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx:
##########
@@ -264,21 +256,13 @@ const ClearTaskInstanceDialog = (props: Props) => {
                 include_future: future,
                 include_past: past,
                 include_upstream: upstream,
+                note: noteChanged ? note : undefined,

Review Comment:
   Also this makes it consistent with the 'bulkClearTaskInstance' which operates the same.



-- 
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] Apply note when clearing a Dag Run / task instances [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #67639:
URL: https://github.com/apache/airflow/pull/67639#issuecomment-4579366207

   ### Backport failed to create: airflow-ctl/v0-1-test. View the failure log <a href='https://github.com/apache/airflow/actions/runs/26659006772'> Run details </a>
   
   Note: As of [Merging PRs targeted for Airflow 3.X](https://github.com/apache/airflow/blob/main/dev/README_AIRFLOW3_DEV.md#merging-prs-targeted-for-airflow-3x)
   the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.
   
   In matter of doubt please ask in [#release-management](https://apache-airflow.slack.com/archives/C03G9H97MM2) Slack channel.
   
   <table>
       <tr>
           <th>Status</th>
           <th>Branch</th>
           <th>Result</th>
       </tr>
       <tr>
           <td>❌</td>
           <td>airflow-ctl/v0-1-test</td>
           <td><a href="https://github.com/apache/airflow/commit/530bbb3af576a40b4cc81c0109405ef66a4817e0"><img src='https://img.shields.io/badge/Commit-530bbb3-red' alt='Commit Link'></a></td>
       </tr>
   </table>
   
   You can attempt to backport this manually by running:
   
   ```bash
   cherry_picker 530bbb3 airflow-ctl/v0-1-test
   ```
   
   This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
   the files that need manual conflict resolution.
   
   After you have resolved the conflicts, you can continue the backport process by running:
   
   ```bash
   cherry_picker --continue
   ```
   
   If you don't have cherry-picker installed, see the [installation guide](https://github.com/apache/airflow/blob/main/dev/README.md#how-to-backport-pr-with-cherry-picker-cli).
   


-- 
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] Apply note when clearing a Dag Run / task instances [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #67639:
URL: https://github.com/apache/airflow/pull/67639#discussion_r3324701227


##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx:
##########
@@ -264,21 +256,13 @@ const ClearTaskInstanceDialog = (props: Props) => {
                 include_future: future,
                 include_past: past,
                 include_upstream: upstream,
+                note: noteChanged ? note : undefined,

Review Comment:
   Moving the note into the clear body changes its scope. The old `mutatePatchTaskInstance` call targeted only this task (`taskId` + `mapIndex`), but the clear body's note is applied by the backend's `_patch_task_instance_note`, which loops over the entire `dag.clear()` result set. Since this dialog defaults `selectedOptions` to `["downstream"]`, clearing a single task with a note now writes that note onto every downstream task instance too, overwriting any notes those tasks already had. Was applying the note to the whole cleared set intended, or should it stay scoped to the selected TI?



##########
airflow-core/src/airflow/ui/src/queries/useBulkClearDagRuns.ts:
##########
@@ -106,6 +106,7 @@ export const useBulkClearDagRuns = ({ deselectKeys, onSuccessConfirm }: Props) =
           dagRunId: dagRun.dag_run_id,
           requestBody: {
             dry_run: false,
+            note: options.note ?? undefined,

Review Comment:
   Worth checking the failure semantics here. The note now rides along with the clear request, so a note that fails validation (e.g. over `max_length=1000`) returns 422 and fails the clear for that run. The old flow cleared first, then patched notes in a separate `Promise.allSettled`, so a bad note did not block the clear and its error surfaced on its own. If that separation mattered, this is a behavior change; if not, fine to drop.



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