feat: invalid password error message (Postgres) (#14038)

This commit is contained in:
Beto Dealmeida 2021-04-12 14:03:21 -07:00 committed by GitHub
parent c563ea091e
commit 786dadc836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 0 deletions

View File

@ -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.

View File

@ -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',

View File

@ -57,6 +57,9 @@ class FixedOffsetTimezone(_FixedOffset):
# Regular expressions to catch custom errors
INVALID_USERNAME_REGEX = re.compile('role "(?P<username>.*?)" does not exist')
INVALID_PASSWORD_REGEX = re.compile(
'password authentication failed for user "(?P<username>.*?)"'
)
INVALID_HOSTNAME_REGEX = re.compile(
'could not translate host name "(?P<hostname>.*?)" 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,

View File

@ -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 @@ ERROR_TYPES_TO_ISSUE_CODES_MAPPING = {
),
},
],
SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR: [
{
"code": 1013,
"message": _(
"Issue 1013 - The password provided when "
"connecting to a database is not valid."
),
},
],
}

View File

@ -298,3 +298,14 @@ psql: error: could not connect to server: Operation timed out
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"},
)
]