mirror of https://github.com/apache/superset.git
feat: invalid DB name error messages (MySQL/Postgres/Redshift) (#14146)
* initial DB custom errors for mysql * added redshift and postgres
This commit is contained in:
parent
8ef572a412
commit
eadff5f41e
|
@ -156,5 +156,13 @@ password is typed correctly.
|
|||
Either the username or the password used are incorrect.
|
||||
```
|
||||
|
||||
Either the username provided does not exist or the password was written
|
||||
incorrectly. Please check that the username and password were typed correctly.
|
||||
Either the username provided does not exist or the password was written incorrectly. Please
|
||||
check that the username and password were typed correctly.
|
||||
|
||||
## Issue 1015
|
||||
|
||||
```
|
||||
Either the database is spelled incorrectly or does not exist.
|
||||
```
|
||||
|
||||
Either the database was written incorrectly or it does not exist. Check that it was typed correctly.
|
||||
|
|
|
@ -37,6 +37,8 @@ export const ErrorTypeEnum = {
|
|||
TEST_CONNECTION_PORT_CLOSED_ERROR: 'TEST_CONNECTION_PORT_CLOSED_ERROR',
|
||||
TEST_CONNECTION_HOST_DOWN_ERROR: 'TEST_CONNECTION_HOST_DOWN_ERROR',
|
||||
TEST_CONNECTION_ACCESS_DENIED_ERROR: 'TEST_CONNECTION_ACCESS_DENIED_ERROR',
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_ERROR:
|
||||
'TEST_CONNECTION_UNKNOWN_DATABASE_ERROR',
|
||||
|
||||
// Viz errors
|
||||
VIZ_GET_DF_ERROR: 'VIZ_GET_DF_ERROR',
|
||||
|
|
|
@ -50,6 +50,9 @@ TEST_CONNECTION_INVALID_HOSTNAME_REGEX = re.compile(
|
|||
TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
|
||||
"Can't connect to MySQL server on '(?P<hostname>.*?)'."
|
||||
)
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
|
||||
"Unknown database '(?P<database>.*?)'."
|
||||
)
|
||||
|
||||
|
||||
class MySQLEngineSpec(BaseEngineSpec):
|
||||
|
@ -119,6 +122,13 @@ class MySQLEngineSpec(BaseEngineSpec):
|
|||
__('The host "%(hostname)s" might be down and can\'t be reached.'),
|
||||
SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR,
|
||||
),
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: (
|
||||
__(
|
||||
'We were unable to connect to your database named "%(database)s". '
|
||||
"Please verify your database name and try again."
|
||||
),
|
||||
SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -76,6 +76,9 @@ TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
|
|||
r'host "(?P<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
|
||||
r"connections on port (?P<port>.*?)\?"
|
||||
)
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
|
||||
'database "(?P<database>.*?)" does not exist'
|
||||
)
|
||||
|
||||
|
||||
class PostgresBaseEngineSpec(BaseEngineSpec):
|
||||
|
@ -120,6 +123,13 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
|
|||
),
|
||||
SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR,
|
||||
),
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: (
|
||||
__(
|
||||
'We were unable to connect to your database named "%(database)s".'
|
||||
" Please verify your database name and try again."
|
||||
),
|
||||
SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -39,6 +39,9 @@ TEST_CONNECTION_HOST_DOWN_REGEX = re.compile(
|
|||
r'host "(?P<hostname>.*?)" (\(.*?\) )?and accepting\s+TCP/IP '
|
||||
r"connections on port (?P<port>.*?)\?"
|
||||
)
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX = re.compile(
|
||||
'database "(?P<database>.*?)" does not exist'
|
||||
)
|
||||
|
||||
|
||||
class RedshiftEngineSpec(PostgresBaseEngineSpec):
|
||||
|
@ -66,6 +69,13 @@ class RedshiftEngineSpec(PostgresBaseEngineSpec):
|
|||
),
|
||||
SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR,
|
||||
),
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_REGEX: (
|
||||
__(
|
||||
'We were unable to connect to your database named "%(database)s".'
|
||||
" Please verify your database name and try again."
|
||||
),
|
||||
SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -45,6 +45,7 @@ class SupersetErrorType(str, Enum):
|
|||
TEST_CONNECTION_PORT_CLOSED_ERROR = "TEST_CONNECTION_PORT_CLOSED_ERROR"
|
||||
TEST_CONNECTION_HOST_DOWN_ERROR = "TEST_CONNECTION_HOST_DOWN_ERROR"
|
||||
TEST_CONNECTION_ACCESS_DENIED_ERROR = "TEST_CONNECTION_ACCESS_DENIED_ERROR"
|
||||
TEST_CONNECTION_UNKNOWN_DATABASE_ERROR = "TEST_CONNECTION_UNKNOWN_DATABASE_ERROR"
|
||||
|
||||
# Viz errors
|
||||
VIZ_GET_DF_ERROR = "VIZ_GET_DF_ERROR"
|
||||
|
@ -180,6 +181,15 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = {
|
|||
"message": _("Issue 1014 - Either the username or the password is wrong."),
|
||||
}
|
||||
],
|
||||
SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR: [
|
||||
{
|
||||
"code": 1015,
|
||||
"message": _(
|
||||
"Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist."
|
||||
),
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -122,7 +122,8 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1014,
|
||||
"message": "Issue 1014 - Either the username or the password is wrong.",
|
||||
"message": "Issue 1014 - Either the"
|
||||
" username or the password is wrong.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -141,7 +142,8 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1007,
|
||||
"message": "Issue 1007 - The hostname provided can't be resolved.",
|
||||
"message": "Issue 1007 - The hostname"
|
||||
" provided can't be resolved.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -153,14 +155,16 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec):
|
|||
assert result == [
|
||||
SupersetError(
|
||||
error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR,
|
||||
message='The host "badconnection.com" might be down and can\'t be reached.',
|
||||
message='The host "badconnection.com" might be '
|
||||
"down and can't be reached.",
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "MySQL",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 1007,
|
||||
"message": "Issue 1007 - The hostname provided can't be resolved.",
|
||||
"message": "Issue 1007 - The hostname provided"
|
||||
" can't be resolved.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -179,7 +183,29 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 10007,
|
||||
"message": "Issue 1007 - The hostname provided can't be resolved.",
|
||||
"message": "Issue 1007 - The hostname provided "
|
||||
"can't be resolved.",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
msg = "mysql: Unknown database 'badDB'."
|
||||
result = MySQLEngineSpec.extract_errors(Exception(msg))
|
||||
assert result == [
|
||||
SupersetError(
|
||||
error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
message='We were unable to connect to your database named "badDB".'
|
||||
" Please verify your database name and try again.",
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "MySQL",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 10015,
|
||||
"message": "Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
|
|
@ -238,7 +238,10 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec):
|
|||
)
|
||||
]
|
||||
|
||||
msg = 'psql: error: could not translate host name "locahost" to address: nodename nor servname provided, or not known'
|
||||
msg = (
|
||||
'psql: error: could not translate host name "locahost" to address: '
|
||||
"nodename nor servname provided, or not known"
|
||||
)
|
||||
result = PostgresEngineSpec.extract_errors(Exception(msg))
|
||||
assert result == [
|
||||
SupersetError(
|
||||
|
@ -250,7 +253,8 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1007,
|
||||
"message": "Issue 1007 - The hostname provided can't be resolved.",
|
||||
"message": "Issue 1007 - The hostname provided "
|
||||
"can't be resolved.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -303,7 +307,8 @@ psql: error: could not connect to server: Operation timed out
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1009,
|
||||
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
|
||||
"message": "Issue 1009 - The host might be down, "
|
||||
"and can't be reached on the provided port.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -332,7 +337,8 @@ psql: error: could not connect to server: Operation timed out
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1009,
|
||||
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
|
||||
"message": "Issue 1009 - The host might be down, "
|
||||
"and can't be reached on the provided port.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -360,3 +366,24 @@ psql: error: could not connect to server: Operation timed out
|
|||
},
|
||||
)
|
||||
]
|
||||
|
||||
msg = 'database "badDB" does not exist'
|
||||
result = PostgresEngineSpec.extract_errors(Exception(msg))
|
||||
assert result == [
|
||||
SupersetError(
|
||||
error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
message='We were unable to connect to your database named "badDB".'
|
||||
" Please verify your database name and try again.",
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "PostgreSQL",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 10015,
|
||||
"message": "Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist.",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
|
|
@ -39,14 +39,18 @@ class TestRedshiftDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1014,
|
||||
"message": "Issue 1014 - Either the username or the password is wrong",
|
||||
"message": "Issue 1014 - Either the username or "
|
||||
"the password is wrong",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
msg = 'redshift: error: could not translate host name "badhost" to address: nodename nor servname provided, or not known'
|
||||
msg = (
|
||||
'redshift: error: could not translate host name "badhost" '
|
||||
"to address: nodename nor servname provided, or not known"
|
||||
)
|
||||
result = RedshiftEngineSpec.extract_errors(Exception(msg))
|
||||
assert result == [
|
||||
SupersetError(
|
||||
|
@ -58,7 +62,8 @@ class TestRedshiftDbEngineSpec(TestDbEngineSpec):
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1007,
|
||||
"message": "Issue 1007 - The hostname provided can't be resolved.",
|
||||
"message": "Issue 1007 - The hostname provided "
|
||||
"can't be resolved.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -110,7 +115,8 @@ psql: error: could not connect to server: Operation timed out
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1009,
|
||||
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
|
||||
"message": "Issue 1009 - The host might be down, "
|
||||
"and can't be reached on the provided port.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -139,7 +145,29 @@ psql: error: could not connect to server: Operation timed out
|
|||
"issue_codes": [
|
||||
{
|
||||
"code": 1009,
|
||||
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
|
||||
"message": "Issue 1009 - The host might be down, "
|
||||
"and can't be reached on the provided port.",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
]
|
||||
|
||||
msg = 'database "badDB" does not exist'
|
||||
result = RedshiftEngineSpec.extract_errors(Exception(msg))
|
||||
assert result == [
|
||||
SupersetError(
|
||||
error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
|
||||
message='We were unable to connect to your database named "badDB".'
|
||||
" Please verify your database name and try again.",
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={
|
||||
"engine_name": "Amazon Redshift",
|
||||
"issue_codes": [
|
||||
{
|
||||
"code": 10015,
|
||||
"message": "Issue 1015 - Either the database is "
|
||||
"spelled incorrectly or does not exist.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue