This is an automated email from the ASF dual-hosted git repository.

justinpark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new f25795c4e4 fix(dashboard): missing null check in error extra (#27845)
f25795c4e4 is described below

commit f25795c4e49cd5c2876da8e0693d6c1511fbcc77
Author: JUST.in DO IT <[email protected]>
AuthorDate: Tue Apr 2 09:20:43 2024 -0700

    fix(dashboard): missing null check in error extra (#27845)
---
 .../src/components/ErrorMessage/DatabaseErrorMessage.test.tsx    | 9 ++++++++-
 .../src/components/ErrorMessage/DatabaseErrorMessage.tsx         | 4 ++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx 
b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
index 78a02a27ee..0a1ad27299 100644
--- 
a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
+++ 
b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.test.tsx
@@ -56,7 +56,14 @@ const mockedProps = {
 };
 
 test('should render', () => {
-  const { container } = render(<DatabaseErrorMessage {...mockedProps} />);
+  const nullExtraProps = {
+    ...mockedProps,
+    error: {
+      ...mockedProps.error,
+      extra: null,
+    },
+  };
+  const { container } = render(<DatabaseErrorMessage {...nullExtraProps} />);
   expect(container).toBeInTheDocument();
 });
 
diff --git 
a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx 
b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
index a7a0a4199f..bf2d013fd0 100644
--- a/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
+++ b/superset-frontend/src/components/ErrorMessage/DatabaseErrorMessage.tsx
@@ -36,7 +36,7 @@ function DatabaseErrorMessage({
   error,
   source = 'dashboard',
   subtitle,
-}: ErrorMessageComponentProps<DatabaseErrorExtra>) {
+}: ErrorMessageComponentProps<DatabaseErrorExtra | null>) {
   const { extra, level, message } = error;
 
   const isVisualization = ['dashboard', 'explore'].includes(source);
@@ -47,7 +47,7 @@ function DatabaseErrorMessage({
         {t('This may be triggered by:')}
         <br />
         {extra.issue_codes
-          .map<React.ReactNode>(issueCode => (
+          ?.map<React.ReactNode>(issueCode => (
             <IssueCode {...issueCode} key={issueCode.code} />
           ))
           .reduce((prev, curr) => [prev, <br />, curr])}

Reply via email to