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 8b471383adc UI: Keep import-error count failures out of the page
(#76954)
8b471383adc is described below
commit 8b471383adcbcc406a78289543331d9886dd5a60
Author: Brent Bovenzi <[email protected]>
AuthorDate: Mon Nov 16 12:00:11 2026 -0500
UI: Keep import-error count failures out of the page (#76954)
When refreshing the Dag or plugin import-error count failed, a full-width
error banner appeared next to the count on the Dashboard, the Dags list
and the Plugins page. Users can't act on it, it repeats failures the page
already reports, and it pushes the rest of the page down. The failed
request is still visible in the browser's network tools.
Co-authored-by: Claude <[email protected]>
---
.../pages/Dashboard/Stats/DagImportErrors.test.tsx | 58 ++++++++++++++++++++++
.../src/pages/Dashboard/Stats/DagImportErrors.tsx | 4 +-
.../Dashboard/Stats/PluginImportErrors.test.tsx | 55 ++++++++++++++++++++
.../pages/Dashboard/Stats/PluginImportErrors.tsx | 8 +--
4 files changed, 115 insertions(+), 10 deletions(-)
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.test.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.test.tsx
new file mode 100644
index 00000000000..08313c42747
--- /dev/null
+++
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.test.tsx
@@ -0,0 +1,58 @@
+/*!
+ * 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, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+
+import "src/i18n/config";
+import { Wrapper } from "src/utils/Wrapper";
+
+import { DagImportErrors } from "./DagImportErrors";
+
+const { mockUseImportErrorServiceGetImportErrors } = vi.hoisted(() => ({
+ mockUseImportErrorServiceGetImportErrors: vi.fn(),
+}));
+
+vi.mock("openapi/queries/queries", async (importOriginal) => {
+ const actual = await importOriginal();
+
+ return {
+ ...(actual as object),
+ useImportErrorServiceGetImportErrors:
mockUseImportErrorServiceGetImportErrors,
+ };
+});
+
+describe("DagImportErrors", () => {
+ it("keeps the last count without an error banner when a refetch fails", ()
=> {
+ mockUseImportErrorServiceGetImportErrors.mockReturnValue({
+ data: { import_errors: [], total_entries: 3 },
+ error: Object.assign(new Error("Internal Server Error"), { status: 500
}),
+ isLoading: false,
+ });
+
+ render(
+ <Wrapper>
+ <DagImportErrors />
+ </Wrapper>,
+ );
+
+ expect(screen.getByTestId("stats-card")).toHaveTextContent("3");
+ expect(screen.queryByTestId("error-alert")).not.toBeInTheDocument();
+ });
+});
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.tsx
index b650e07afe5..5a326b114fe 100644
--- a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.tsx
+++ b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/DagImportErrors.tsx
@@ -22,7 +22,6 @@ import { LuFileWarning } from "react-icons/lu";
import { useImportErrorServiceGetImportErrors } from "openapi/queries/queries";
-import { ErrorAlert } from "src/components/ErrorAlert";
import { StateBadge } from "src/components/StateBadge";
import { StatsCard } from "src/components/StatsCard";
@@ -36,7 +35,7 @@ export const DagImportErrors = ({ iconOnly = false }: {
readonly iconOnly?: bool
const isRTL = i18n.dir() === "rtl";
- const { data, error, isLoading } = useImportErrorServiceGetImportErrors({
limit: 1 });
+ const { data, isLoading } = useImportErrorServiceGetImportErrors({ limit: 1
});
const importErrorsCount = data?.total_entries ?? 0;
if (isLoading) {
@@ -49,7 +48,6 @@ export const DagImportErrors = ({ iconOnly = false }: {
readonly iconOnly?: bool
return (
<Box alignItems="center" display="flex">
- <ErrorAlert error={error} />
{iconOnly ? (
<StateBadge
aria-label={translate("importErrors.dagImportError", { count:
importErrorsCount })}
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.test.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.test.tsx
new file mode 100644
index 00000000000..3f9698c31ab
--- /dev/null
+++
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.test.tsx
@@ -0,0 +1,55 @@
+/*!
+ * 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, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+
+import "src/i18n/config";
+import { Wrapper } from "src/utils/Wrapper";
+
+import { PluginImportErrors } from "./PluginImportErrors";
+
+const { mockUsePluginServiceImportErrors } = vi.hoisted(() => ({
+ mockUsePluginServiceImportErrors: vi.fn(),
+}));
+
+vi.mock("openapi/queries", async (importOriginal) => {
+ const actual = await importOriginal();
+
+ return { ...(actual as object), usePluginServiceImportErrors:
mockUsePluginServiceImportErrors };
+});
+
+describe("PluginImportErrors", () => {
+ it("keeps the last count without an error banner when a refetch fails", ()
=> {
+ mockUsePluginServiceImportErrors.mockReturnValue({
+ data: { import_errors: [], total_entries: 3 },
+ error: Object.assign(new Error("Internal Server Error"), { status: 500
}),
+ isLoading: false,
+ });
+
+ render(
+ <Wrapper>
+ <PluginImportErrors />
+ </Wrapper>,
+ );
+
+ expect(screen.getByTestId("stats-card")).toHaveTextContent("3");
+ expect(screen.queryByTestId("error-alert")).not.toBeInTheDocument();
+ });
+});
diff --git
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.tsx
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.tsx
index a72cf86766c..db9772bcb21 100644
---
a/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.tsx
+++
b/airflow-core/src/airflow/ui/src/pages/Dashboard/Stats/PluginImportErrors.tsx
@@ -22,7 +22,6 @@ import { LuPlug } from "react-icons/lu";
import { usePluginServiceImportErrors } from "openapi/queries";
-import { ErrorAlert, type ExpandedApiError } from "src/components/ErrorAlert";
import { StateBadge } from "src/components/StateBadge";
import { StatsCard } from "src/components/StatsCard";
@@ -33,7 +32,7 @@ import { PluginImportErrorsModal } from
"./PluginImportErrorsModal";
export const PluginImportErrors = ({ iconOnly = false }: { readonly iconOnly?:
boolean }) => {
const { onClose, onOpen, open } = useDisclosure();
const { i18n, t: translate } = useTranslation("admin");
- const { data, error, isLoading } = usePluginServiceImportErrors();
+ const { data, isLoading } = usePluginServiceImportErrors();
const isRTL = i18n.dir() === "rtl";
@@ -44,17 +43,12 @@ export const PluginImportErrors = ({ iconOnly = false }: {
readonly iconOnly?: b
return <Skeleton height="9" width="225px" />;
}
- if (Boolean(error) && (error as ExpandedApiError).status === 403) {
- return undefined;
- }
-
if (importErrorsCount === 0) {
return undefined;
}
return (
<Box alignItems="center" display="flex">
- <ErrorAlert error={error} />
{iconOnly ? (
<StateBadge
as={Button}