diff --git a/superset/databases/commands/test_connection.py b/superset/databases/commands/test_connection.py index 4f4b915f06..024763060c 100644 --- a/superset/databases/commands/test_connection.py +++ b/superset/databases/commands/test_connection.py @@ -93,6 +93,7 @@ class TestConnectionDatabaseCommand(BaseCommand): "password": url.password, "port": url.port, "username": url.username, + "database": url.database, } errors = database.db_engine_spec.extract_errors(ex, context) raise DatabaseTestConnectionFailedError(errors) diff --git a/superset/db_engine_specs/mssql.py b/superset/db_engine_specs/mssql.py index 980619778a..9e089d4350 100644 --- a/superset/db_engine_specs/mssql.py +++ b/superset/db_engine_specs/mssql.py @@ -66,7 +66,10 @@ class MssqlEngineSpec(BaseEngineSpec): custom_errors = { CONNECTION_ACCESS_DENIED_REGEX: ( - __('Either the username "%(username)s" or the password is incorrect.'), + __( + 'Either the username "%(username)s", password, ' + 'or database name "%(database)s" is incorrect.' + ), SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, ), CONNECTION_INVALID_HOSTNAME_REGEX: ( diff --git a/superset/errors.py b/superset/errors.py index d8049719cf..f4845aa288 100644 --- a/superset/errors.py +++ b/superset/errors.py @@ -179,7 +179,14 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = { { "code": 1014, "message": _("Issue 1014 - Either the username or the password is wrong."), - } + }, + { + "code": 1015, + "message": _( + "Issue 1015 - Either the database is " + "spelled incorrectly or does not exist." + ), + }, ], SupersetErrorType.CONNECTION_UNKNOWN_DATABASE_ERROR: [ { diff --git a/tests/db_engine_specs/mssql_tests.py b/tests/db_engine_specs/mssql_tests.py index 0822f426ee..b37bb371ce 100644 --- a/tests/db_engine_specs/mssql_tests.py +++ b/tests/db_engine_specs/mssql_tests.py @@ -284,11 +284,11 @@ Adaptive Server connection failed (mssqldb.cxiotftzsypc.us-west-2.rds.amazonaws. """ ) result = MssqlEngineSpec.extract_errors( - Exception(msg), context={"username": "testuser"} + Exception(msg), context={"username": "testuser", "database": "testdb"} ) assert result == [ SupersetError( - message='Either the username "testuser" or the password is incorrect.', + message='Either the username "testuser", password, or database name "testdb" is incorrect.', error_type=SupersetErrorType.CONNECTION_ACCESS_DENIED_ERROR, level=ErrorLevel.ERROR, extra={ @@ -296,8 +296,14 @@ Adaptive Server connection failed (mssqldb.cxiotftzsypc.us-west-2.rds.amazonaws. "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.", + }, + { + "code": 1015, + "message": "Issue 1015 - Either the database is " + "spelled incorrectly or does not exist.", + }, ], }, ) diff --git a/tests/db_engine_specs/mysql_tests.py b/tests/db_engine_specs/mysql_tests.py index e732bf4381..fff54e1cd5 100644 --- a/tests/db_engine_specs/mysql_tests.py +++ b/tests/db_engine_specs/mysql_tests.py @@ -124,7 +124,12 @@ class TestMySQLEngineSpecsDbEngineSpec(TestDbEngineSpec): "code": 1014, "message": "Issue 1014 - Either the" " username or the password is wrong.", - } + }, + { + "code": 1015, + "message": "Issue 1015 - Either the database is " + "spelled incorrectly or does not exist.", + }, ], }, ) diff --git a/tests/db_engine_specs/redshift_tests.py b/tests/db_engine_specs/redshift_tests.py index ff97ebee42..483fbe54b2 100644 --- a/tests/db_engine_specs/redshift_tests.py +++ b/tests/db_engine_specs/redshift_tests.py @@ -15,7 +15,6 @@ # specific language governing permissions and limitations # under the License. from textwrap import dedent -from unittest import mock from superset.db_engine_specs.redshift import RedshiftEngineSpec from superset.errors import ErrorLevel, SupersetError, SupersetErrorType @@ -39,9 +38,14 @@ 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.", + }, + { + "code": 1015, + "message": "Issue 1015 - Either the database is " + "spelled incorrectly or does not exist.", + }, ], }, )