mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
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:
@@ -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.",
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user