This is an automated email from the ASF dual-hosted git repository.
bbovenzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 60d692ba674 Stop requesting the details of an empty Dag id after a
bulk selection (#75862)
60d692ba674 is described below
commit 60d692ba674e46a5ab4940d4f5ac0aa0e61d1de2
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Wed Oct 28 14:31:05 2026 +0100
Stop requesting the details of an empty Dag id after a bulk selection
(#75862)
* Stop requesting the details of an empty Dag id after a bulk selection
The Task Instances list keeps its bulk Clear dialog mounted once every row
is unselected. With nothing to clear, the dialog's Dag id was an empty
string, which still enabled the auto-refresh lookup and sent
GET /dags//details, answered with a 404.
* Leave the Clear dialog's Dag id undefined when there is nothing to clear
An empty-string fallback on the shared Dag id lets any later use send it
unnoticed. Only the two Dag and Dag run lookups need a string, and they
run for a single run, when the Dag id is always set.
---
...ClearTaskInstanceDialog.emptySelection.test.tsx | 44 ++++++++++++++++++++++
.../Clear/TaskInstance/ClearTaskInstanceDialog.tsx | 9 +++--
2 files changed, 50 insertions(+), 3 deletions(-)
diff --git
a/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.emptySelection.test.tsx
b/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.emptySelection.test.tsx
new file mode 100644
index 00000000000..9bb4180358d
--- /dev/null
+++
b/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.emptySelection.test.tsx
@@ -0,0 +1,44 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import "@testing-library/jest-dom/vitest";
+import { render } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { DagService } from "openapi/requests/services.gen";
+
+import { Wrapper } from "src/utils/Wrapper";
+
+import ClearTaskInstanceDialog from "./ClearTaskInstanceDialog";
+
+afterEach(() => vi.restoreAllMocks());
+
+describe("ClearTaskInstanceDialog without task instances", () => {
+ it("does not request the details of an empty Dag id", async () => {
+ const getDagDetails = vi.spyOn(DagService, "getDagDetails");
+
+ render(<ClearTaskInstanceDialog onClose={vi.fn()} open={false}
taskInstances={[]} />, {
+ wrapper: Wrapper,
+ });
+ await new Promise((resolve) => {
+ setTimeout(resolve, 50);
+ });
+
+ expect(getDagDetails).not.toHaveBeenCalled();
+ });
+});
diff --git
a/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx
b/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx
index b97a9a6247e..cc504f36904 100644
---
a/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx
+++
b/airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx
@@ -155,7 +155,8 @@ const ClearTaskInstanceDialog = (props: Props) => {
// The Dag details and run versions behind the run-on-latest option are read
for one run.
const singleRun = groups.length === 1;
- const dagId = groups[0]?.dagId ?? "";
+ // Undefined while there is nothing to clear: the bulk actions keep this
dialog mounted.
+ const dagId = groups[0]?.dagId;
const dagRunId = groups[0]?.dagRunId ?? "";
const loopMode = targets.some((target) => target.in_loop);
const initialNote = targets.length === 1 ? (targets[0]?.note ?? null) : null;
@@ -201,9 +202,11 @@ const ClearTaskInstanceDialog = (props: Props) => {
closeDialog();
};
- const { data: dagDetails } = useDagServiceGetDagDetails({ dagId },
undefined, { enabled: singleRun });
+ const { data: dagDetails } = useDagServiceGetDagDetails({ dagId: dagId ?? ""
}, undefined, {
+ enabled: singleRun,
+ });
- const { data: dagRun } = useDagRunServiceGetDagRun({ dagId, dagRunId },
undefined, {
+ const { data: dagRun } = useDagRunServiceGetDagRun({ dagId: dagId ?? "",
dagRunId }, undefined, {
enabled: openDialog && singleRun,
});