From de52f1c26fb5dc277074261caea4e67b74807c80 Mon Sep 17 00:00:00 2001 From: Yeonguk Choo Date: Tue, 25 Nov 2025 01:29:01 +0900 Subject: [PATCH] [v3-1-test] Improve 404 handling by adding fallback route for invalid URLs (#58546) * Add error handling route to catch unmatched paths * Add custom 404 error message for invalid URLs (cherry picked from commit 946871c27de7b7e72abad646ffbd65b163d98139) Co-authored-by: Yeonguk Choo --- .../src/airflow/ui/public/i18n/locales/en/common.json | 1 + airflow-core/src/airflow/ui/src/pages/Error.tsx | 5 ++++- airflow-core/src/airflow/ui/src/router.tsx | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json b/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json index 211244bd68480..8aee7cb16deec 100644 --- a/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json +++ b/airflow-core/src/airflow/ui/public/i18n/locales/en/common.json @@ -89,6 +89,7 @@ "back": "Back", "defaultMessage": "An unexpected error occurred", "home": "Home", + "invalidUrl": "Page Not Found. Please check the URL and try again.", "notFound": "Page Not Found", "title": "Error" }, diff --git a/airflow-core/src/airflow/ui/src/pages/Error.tsx b/airflow-core/src/airflow/ui/src/pages/Error.tsx index 7b9ee1b8a3950..28fa9ec84af98 100644 --- a/airflow-core/src/airflow/ui/src/pages/Error.tsx +++ b/airflow-core/src/airflow/ui/src/pages/Error.tsx @@ -30,7 +30,10 @@ export const ErrorPage = () => { let errorMessage = translate("error.defaultMessage"); let statusCode = ""; - if (isRouteErrorResponse(error)) { + if (error === null || error === undefined) { + statusCode = "404"; + errorMessage = translate("error.invalidUrl"); + } else if (isRouteErrorResponse(error)) { statusCode = String(error.status); errorMessage = ((error as unknown as Error).message || (error as { statusText?: string }).statusText) ?? diff --git a/airflow-core/src/airflow/ui/src/router.tsx b/airflow-core/src/airflow/ui/src/router.tsx index 052096eaa1d5f..5c3ddc76174e2 100644 --- a/airflow-core/src/airflow/ui/src/router.tsx +++ b/airflow-core/src/airflow/ui/src/router.tsx @@ -227,6 +227,10 @@ export const routerConfig = [ element: , path: "dags/:dagId/tasks/:taskId", }, + { + element: , + path: "*", + }, ], element: , errorElement: (