diff --git a/docs/src/pages/docs/Miscellaneous/issue_codes.mdx b/docs/src/pages/docs/Miscellaneous/issue_codes.mdx index 54e255f28f788..1a83ef5ef24ed 100644 --- a/docs/src/pages/docs/Miscellaneous/issue_codes.mdx +++ b/docs/src/pages/docs/Miscellaneous/issue_codes.mdx @@ -140,3 +140,12 @@ The username provided when connecting to a database is not valid. The user provided a username that doesn't exist in the database. Please check that the username is typed correctly and exists in the database. + +## Issue 1013 + +``` +The password provided when connecting to a database is not valid. +``` + +The user provided a password that is incorrect. Please check that the +password is typed correctly. diff --git a/superset-frontend/src/components/ErrorMessage/types.ts b/superset-frontend/src/components/ErrorMessage/types.ts index dccb29aed53ea..7c98fcc593bda 100644 --- a/superset-frontend/src/components/ErrorMessage/types.ts +++ b/superset-frontend/src/components/ErrorMessage/types.ts @@ -30,6 +30,8 @@ export const ErrorTypeEnum = { TABLE_DOES_NOT_EXIST_ERROR: 'TABLE_DOES_NOT_EXIST_ERROR', TEST_CONNECTION_INVALID_USERNAME_ERROR: 'TEST_CONNECTION_INVALID_USERNAME_ERROR', + TEST_CONNECTION_INVALID_PASSWORD_ERROR: + 'TEST_CONNECTION_INVALID_PASSWORD_ERROR', TEST_CONNECTION_INVALID_HOSTNAME_ERROR: 'TEST_CONNECTION_INVALID_HOSTNAME_ERROR', TEST_CONNECTION_PORT_CLOSED_ERROR: 'TEST_CONNECTION_PORT_CLOSED_ERROR', diff --git a/superset/db_engine_specs/postgres.py b/superset/db_engine_specs/postgres.py index b3548a0a3777c..15615b1133e0e 100644 --- a/superset/db_engine_specs/postgres.py +++ b/superset/db_engine_specs/postgres.py @@ -57,6 +57,9 @@ class FixedOffsetTimezone(_FixedOffset): # Regular expressions to catch custom errors INVALID_USERNAME_REGEX = re.compile('role "(?P.*?)" does not exist') +INVALID_PASSWORD_REGEX = re.compile( + 'password authentication failed for user "(?P.*?)"' +) INVALID_HOSTNAME_REGEX = re.compile( 'could not translate host name "(?P.*?)" to address: ' "nodename nor servname provided, or not known" @@ -96,6 +99,10 @@ class PostgresBaseEngineSpec(BaseEngineSpec): __('The username "%(username)s" does not exist.'), SupersetErrorType.TEST_CONNECTION_INVALID_USERNAME_ERROR, ), + INVALID_PASSWORD_REGEX: ( + __('The password provided for username "%(username)s" is incorrect.'), + SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR, + ), INVALID_HOSTNAME_REGEX: ( __('The hostname "%(hostname)s" cannot be resolved.'), SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, diff --git a/superset/errors.py b/superset/errors.py index 9dfbede79a0f5..16d2216d9be9c 100644 --- a/superset/errors.py +++ b/superset/errors.py @@ -40,6 +40,7 @@ class SupersetErrorType(str, Enum): COLUMN_DOES_NOT_EXIST_ERROR = "COLUMN_DOES_NOT_EXIST_ERROR" TABLE_DOES_NOT_EXIST_ERROR = "TABLE_DOES_NOT_EXIST_ERROR" TEST_CONNECTION_INVALID_USERNAME_ERROR = "TEST_CONNECTION_INVALID_USERNAME_ERROR" + TEST_CONNECTION_INVALID_PASSWORD_ERROR = "TEST_CONNECTION_INVALID_PASSWORD_ERROR" TEST_CONNECTION_INVALID_HOSTNAME_ERROR = "TEST_CONNECTION_INVALID_HOSTNAME_ERROR" TEST_CONNECTION_PORT_CLOSED_ERROR = "TEST_CONNECTION_PORT_CLOSED_ERROR" TEST_CONNECTION_HOST_DOWN_ERROR = "TEST_CONNECTION_HOST_DOWN_ERROR" @@ -163,6 +164,15 @@ class SupersetErrorType(str, Enum): ), }, ], + SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR: [ + { + "code": 1013, + "message": _( + "Issue 1013 - The password provided when " + "connecting to a database is not valid." + ), + }, + ], } diff --git a/tests/db_engine_specs/postgres_tests.py b/tests/db_engine_specs/postgres_tests.py index 813cc498e84d9..aae14e8d66e48 100644 --- a/tests/db_engine_specs/postgres_tests.py +++ b/tests/db_engine_specs/postgres_tests.py @@ -298,3 +298,14 @@ def test_extract_errors(self): extra={"engine_name": "PostgreSQL"}, ) ] + + msg = 'FATAL: password authentication failed for user "postgres"' + result = PostgresEngineSpec.extract_errors(Exception(msg)) + assert result == [ + SupersetError( + error_type=SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR, + message=('The password provided for username "postgres" is incorrect.'), + level=ErrorLevel.ERROR, + extra={"engine_name": "PostgreSQL"}, + ) + ]