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

rusackas 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 e118b4d733 fix: Dashboard import holding issue (#19112)
e118b4d733 is described below

commit e118b4d733c6355127b6a1713c50a423168b5f42
Author: Smart-Codi <[email protected]>
AuthorDate: Tue Apr 5 23:43:47 2022 -0400

    fix: Dashboard import holding issue (#19112)
    
    * fix dashboard import holding issue
    
    * resolve comment
---
 superset-frontend/src/views/CRUD/hooks.ts       |  5 ++++-
 superset-frontend/src/views/CRUD/utils.test.tsx | 25 +++++++++++++++++++++++++
 superset-frontend/src/views/CRUD/utils.tsx      | 20 +++++++++++---------
 3 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/hooks.ts 
b/superset-frontend/src/views/CRUD/hooks.ts
index cdb0cdc838..a3de433247 100644
--- a/superset-frontend/src/views/CRUD/hooks.ts
+++ b/superset-frontend/src/views/CRUD/hooks.ts
@@ -448,7 +448,10 @@ export function useImportResource(
                 t(
                   'An error occurred while importing %s: %s',
                   resourceLabel,
-                  error.errors.map(payload => payload.message).join('\n'),
+                  [
+                    ...error.errors.map(payload => payload.message),
+                    t('Please re-export your file and try importing again'),
+                  ].join('\n'),
                 ),
               );
             } else {
diff --git a/superset-frontend/src/views/CRUD/utils.test.tsx 
b/superset-frontend/src/views/CRUD/utils.test.tsx
index 68d377e310..dcce0b8369 100644
--- a/superset-frontend/src/views/CRUD/utils.test.tsx
+++ b/superset-frontend/src/views/CRUD/utils.test.tsx
@@ -46,6 +46,25 @@ const terminalErrors = {
   ],
 };
 
+const terminalErrorsWithOnlyIssuesCode = {
+  errors: [
+    {
+      message: 'Error importing database',
+      error_type: 'GENERIC_COMMAND_ERROR',
+      level: 'warning',
+      extra: {
+        issue_codes: [
+          {
+            code: 1010,
+            message:
+              'Issue 1010 - Superset encountered an error while running a 
command.',
+          },
+        ],
+      },
+    },
+  ],
+};
+
 const overwriteNeededErrors = {
   errors: [
     {
@@ -146,6 +165,12 @@ test('detects if the error message is terminal or if it 
requires uses interventi
   expect(isTerminal).toBe(false);
 });
 
+test('error message is terminal when the "extra" field contains only the 
"issue_codes" key', () => {
+  expect(hasTerminalValidation(terminalErrorsWithOnlyIssuesCode.errors)).toBe(
+    true,
+  );
+});
+
 test('does not ask for password when the import type is wrong', () => {
   const error = {
     errors: [
diff --git a/superset-frontend/src/views/CRUD/utils.tsx 
b/superset-frontend/src/views/CRUD/utils.tsx
index 7f069a3e7c..1a7b3ca1fa 100644
--- a/superset-frontend/src/views/CRUD/utils.tsx
+++ b/superset-frontend/src/views/CRUD/utils.tsx
@@ -399,15 +399,17 @@ export const getAlreadyExists = (errors: Record<string, 
any>[]) =>
     .flat();
 
 export const hasTerminalValidation = (errors: Record<string, any>[]) =>
-  errors.some(
-    error =>
-      !Object.entries(error.extra)
-        .filter(([key, _]) => key !== 'issue_codes')
-        .every(
-          ([_, payload]) =>
-            isNeedsPassword(payload) || isAlreadyExists(payload),
-        ),
-  );
+  errors.some(error => {
+    const noIssuesCodes = Object.entries(error.extra).filter(
+      ([key]) => key !== 'issue_codes',
+    );
+
+    if (noIssuesCodes.length === 0) return true;
+
+    return !noIssuesCodes.every(
+      ([, payload]) => isNeedsPassword(payload) || isAlreadyExists(payload),
+    );
+  });
 
 export const checkUploadExtensions = (
   perm: Array<string>,

Reply via email to