UI: Use bulk clearDagRuns endpoint for bulk Dag run clear#67846
Open
pierrejeambrun wants to merge 2 commits into
Open
UI: Use bulk clearDagRuns endpoint for bulk Dag run clear#67846pierrejeambrun wants to merge 2 commits into
pierrejeambrun wants to merge 2 commits into
Conversation
3838df0 to
bf8f98f
Compare
Member
Author
Screen.Recording.2026-06-02.at.15.09.56.movScreen.Recording.2026-06-02.at.15.12.37.mov |
Member
Author
53dabe2 to
a7fa62f
Compare
bbovenzi
requested changes
Jun 3, 2026
Comment on lines
+43
to
+74
| const { data: response, isFetching } = useQuery({ | ||
| enabled: enabled && selectedDagRuns.length > 0, | ||
| queryFn: () => | ||
| DagRunService.clearDagRuns({ | ||
| // ``~`` clears across Dags in a single call; every entry carries its own dag_id. | ||
| dagId: "~", | ||
| requestBody: { | ||
| dag_runs: selectedDagRuns.map((dagRun) => ({ | ||
| dag_id: dagRun.dag_id, | ||
| dag_run_id: dagRun.dag_run_id, | ||
| })), | ||
| dry_run: true, | ||
| only_failed: options.onlyFailed, | ||
| only_new: options.onlyNew, | ||
| }, | ||
| }) as Promise<ClearTaskInstanceCollectionResponse>, | ||
| queryKey: [ | ||
| useBulkClearDagRunsDryRunKey, | ||
| selectedDagRuns.map((dagRun) => `${dagRun.dag_id}.${dagRun.dag_run_id}`).sort(), | ||
| { only_failed: options.onlyFailed, only_new: options.onlyNew }, | ||
| ], | ||
| refetchOnMount: "always" as const, | ||
| }); | ||
|
|
||
| const isFetching = results.some((result) => result.isFetching); | ||
| // Each per-run call is scoped to a distinct ``(dag_id, dag_run_id)`` so the | ||
| // concatenated array can't contain duplicates; the response is also | ||
| // homogeneous (``only_new=true`` yields ``NewTaskResponse`` placeholders, | ||
| // ``false`` yields real ``TaskInstanceResponse``), so the cast is safe even | ||
| // though the OpenAPI type widens to a union. | ||
| const taskInstances = results.flatMap((result) => result.data?.task_instances ?? []); | ||
| const data: TaskInstanceCollectionResponse = | ||
| taskInstances.length === 0 | ||
| ? EMPTY | ||
| : { | ||
| task_instances: taskInstances as Array<TaskInstanceResponse>, | ||
| total_entries: taskInstances.length, | ||
| }; | ||
| // ``only_new=true`` yields ``NewTaskResponse`` placeholders, ``false`` yields real | ||
| // ``TaskInstanceResponse``; the OpenAPI type widens to a union, so narrow it here. | ||
| const data: TaskInstanceCollectionResponse = response | ||
| ? { | ||
| task_instances: response.task_instances as Array<TaskInstanceResponse>, | ||
| total_entries: response.total_entries, | ||
| } | ||
| : EMPTY; |
Contributor
There was a problem hiding this comment.
This is a lot of typecasting that I would like to avoid
| dagId: "~", | ||
| requestBody: { | ||
| dag_runs: dagRuns.map((dagRun) => ({ | ||
| dag_id: dagRun.dag_id, |
Contributor
There was a problem hiding this comment.
We shouldn't be handling errors, pending, or even calling the API endpoint directly on our own. Use the hook.
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.

Wires the Dag Runs bulk-clear action to the new
POST /dags/{dag_id}/clearDagRunsbulk endpoint, replacing the previous client-side fan-out that issued one single-run clear request per selected run.useBulkClearDagRunsnow makes a single atomicclearDagRunscall (~wildcard, each entry carries its owndag_id) instead ofPromise.allSettledover per-run calls.useBulkClearDagRunsDryRunnow makes a single dry-run call instead of auseQueriesfan-out.BulkClearDagRunsButtonis unchanged — both hooks keep their signatures and return shapes.Behavior change: the bulk clear is now atomic — all selected runs clear or none do. The previous fan-out allowed partial success (clear the runs that succeed, report per-run errors). This aligns dag-run bulk clear with the existing
post_clear_task_instancesendpoint, which is already a single all-or-nothing transaction. On failure the dialog stays open and shows a single request-level error.Depends on #67709 (the bulk endpoint + regenerated client live on that branch). This PR is stacked on it — until #67709 merges, the diff here also shows #67709's commits; the UI change itself is the single commit "UI: Use bulk clearDagRuns endpoint instead of per-run fan-out".
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8) following the guidelines