Skip to content

Commit

Permalink
fix: import DB errors
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Dec 14, 2021
1 parent 2633bcc commit 863600c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 28 additions & 0 deletions superset-frontend/src/views/CRUD/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,31 @@ test('detects if the error message is terminal or if it requires uses interventi
isTerminal = hasTerminalValidation(passwordNeededErrors.errors);
expect(isTerminal).toBe(false);
});

test('does not ask for password when the import type is wrong', () => {
const error = {
errors: [
{
message: 'Error importing database',
error_type: 'GENERIC_COMMAND_ERROR',
level: 'warning',
extra: {
'metadata.yaml': {
type: ['Must be equal to Database.'],
},
'databases/examples.yaml': {
_schema: ['Must provide a password for the database'],
},
issue_codes: [
{
code: 1010,
message:
'Issue 1010 - Superset encountered an error while running a command.',
},
],
},
},
],
};
expect(hasTerminalValidation(error.errors)).toBe(true);
});
9 changes: 6 additions & 3 deletions superset-frontend/src/views/CRUD/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ export const getAlreadyExists = (errors: Record<string, any>[]) =>
export const hasTerminalValidation = (errors: Record<string, any>[]) =>
errors.some(
error =>
!Object.values(error.extra).some(
payload => isNeedsPassword(payload) || isAlreadyExists(payload),
),
!Object.entries(error.extra)
.filter(([key, _]) => key !== 'issue_codes')
.every(
([_, payload]) =>
isNeedsPassword(payload) || isAlreadyExists(payload),
),
);

0 comments on commit 863600c

Please sign in to comment.