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 f5a994353e4 Copy the stack trace from the Dag import error modals
(#76924)
f5a994353e4 is described below
commit f5a994353e48b7fe13c7cdb42f17a207e60e1732
Author: Brent Bovenzi <[email protected]>
AuthorDate: Wed Nov 11 13:24:34 2026 -0500
Copy the stack trace from the Dag import error modals (#76924)
The copy button in both Dag import error modals (the dashboard list and
the one opened from a Dag) copied the file name, which is already shown
as text next to it. Users reach for the button to share or search the
error, so copy the full stack trace instead.
Co-authored-by: bbovenzi <[email protected]>
---
.../ui/src/components/DagImportErrorDetails.tsx | 2 +-
.../ui/src/components/DagImportErrorModal.test.tsx | 15 +++++-
.../Dashboard/Stats/DagImportErrorsModal.test.tsx | 59 ++++++++++++++++++++++
.../pages/Dashboard/Stats/DagImportErrorsModal.tsx | 2 +-
4 files changed, 75 insertions(+), 3 deletions(-)
diff --git
a/airflow-core/src/airflow/ui/src/components/DagImportErrorDetails.tsx
b/airflow-core/src/airflow/ui/src/components/DagImportErrorDetails.tsx
index 1cb0947ee73..1bed66d728a 100644
--- a/airflow-core/src/airflow/ui/src/components/DagImportErrorDetails.tsx
+++ b/airflow-core/src/airflow/ui/src/components/DagImportErrorDetails.tsx
@@ -51,7 +51,7 @@ export const DagImportErrorDetails = ({ importError }: {
readonly importError: I
<HStack alignItems="center" flexWrap="wrap" gap={2} mb={2}>
<PiFilePy />
{importError.filename}
- <ClipboardRoot value={importError.filename}>
+ <ClipboardRoot value={importError.stack_trace}>
<ClipboardIconButton variant="outline" />
</ClipboardRoot>
<IconButton
diff --git
a/airflow-core/src/airflow/ui/src/components/DagImportErrorModal.test.tsx
b/airflow-core/src/airflow/ui/src/components/DagImportErrorModal.test.tsx
index b6038fca183..4070a1771ee 100644
--- a/airflow-core/src/airflow/ui/src/components/DagImportErrorModal.test.tsx
+++ b/airflow-core/src/airflow/ui/src/components/DagImportErrorModal.test.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import "@testing-library/jest-dom/vitest";
-import { render, screen, within } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor, within } from
"@testing-library/react";
import { http, HttpResponse } from "msw";
import { describe, expect, it, vi } from "vitest";
@@ -49,6 +49,19 @@ describe("DagImportErrorModal", () => {
expect(within(dialog).getByText(/Traceback \(most recent call
last\)/u)).toBeInTheDocument();
});
+ it("copies the stack trace, not the file name", async () => {
+ const writeText = vi.fn<(text: string) =>
Promise<void>>().mockResolvedValue(undefined);
+
+ Object.defineProperty(navigator, "clipboard", { configurable: true, value:
{ writeText } });
+ render(<DagImportErrorModal importError={importError} onClose={vi.fn()}
open />, { wrapper: Wrapper });
+
+ const dialog = screen.getByRole("dialog", { name:
"importErrors.dagImportError" });
+
+ fireEvent.click(within(dialog).getByRole("button", { name: /copy/iu }));
+
+ await waitFor(() =>
expect(writeText).toHaveBeenCalledWith(importError.stack_trace));
+ });
+
it.each([
{ shown: false, totalEntries: 1 },
{ shown: true, totalEntries: 2 },
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.test.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.test.tsx
new file mode 100644
index 00000000000..d38258d9ca0
--- /dev/null
+++
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.test.tsx
@@ -0,0 +1,59 @@
+/*!
+ * 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 { fireEvent, render, screen, waitFor, within } from
"@testing-library/react";
+import { http, HttpResponse } from "msw";
+import { describe, expect, it, vi } from "vitest";
+
+import type { ImportErrorResponse } from "openapi/requests/types.gen";
+
+import { server } from "src/mocks/server";
+import { Wrapper } from "src/utils/Wrapper";
+
+import { DagImportErrorsModal } from "./DagImportErrorsModal";
+
+const importError: ImportErrorResponse = {
+ bundle_name: "dags-folder",
+ file_token: "token",
+ filename: "dags/broken_dag.py",
+ import_error_id: 1,
+ source_reference: null,
+ stack_trace: 'Traceback (most recent call last):\n File
"dags/broken_dag.py", line 1',
+ timestamp: "2025-01-01T00:00:00Z",
+};
+
+describe("DagImportErrorsModal", () => {
+ it("copies the stack trace, not the file name", async () => {
+ server.use(
+ http.get("/api/v2/importErrors", () =>
+ HttpResponse.json({ import_errors: [importError], total_entries: 1 }),
+ ),
+ );
+ const writeText = vi.fn<(text: string) =>
Promise<void>>().mockResolvedValue(undefined);
+
+ Object.defineProperty(navigator, "clipboard", { configurable: true, value:
{ writeText } });
+ render(<DagImportErrorsModal onClose={vi.fn()} open />, { wrapper: Wrapper
});
+
+ const dialog = await screen.findByRole("dialog");
+
+ fireEvent.click(await within(dialog).findByRole("button", { name: /copy/iu
}));
+
+ await waitFor(() =>
expect(writeText).toHaveBeenCalledWith(importError.stack_trace));
+ });
+});
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.tsx
index 5bf9dfe1545..076d981dc3b 100644
---
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.tsx
+++
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrorsModal.tsx
@@ -186,7 +186,7 @@ export const DagImportErrorsModal = ({ onClose, open }:
ImportDAGErrorModalProps
fileToken={importError.file_token}
onReparsed={() => setPollAfterReparse(true)}
/>
- <ClipboardRoot value={importError.filename}>
+ <ClipboardRoot value={importError.stack_trace}>
<ClipboardIconButton variant="outline" />
</ClipboardRoot>
</Box>