mirror of
https://github.com/apache/superset.git
synced 2026-04-18 15:44:57 +00:00
fix: import DB errors (#17748)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user