-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: invalid hostname and password error messages (MySQL) #14089
Conversation
superset/db_engine_specs/mysql.py
Outdated
@@ -93,6 +104,21 @@ class MySQLEngineSpec(BaseEngineSpec): | |||
|
|||
type_code_map: Dict[int, str] = {} # loaded from get_datatype only if needed | |||
|
|||
custom_errors = { | |||
INVALID_ACCESS_REGEX: ( | |||
__('Either the username "%(username)s" or password is incorrect'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... or the password is incorrect." would be better?
Also, all messages should end in a period.
tests/db_engine_specs/mysql_tests.py
Outdated
) | ||
] | ||
|
||
msg = "mysql: Can't connect to MySQL server on 'badconnection.com'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try also with an IP address instead of a name? To see if the message is similar and still gets captured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
psql: error: could not connect to server: Operation timed out Is the server running on host "93.184.216.34" and accepting TCP/IP connections on port 12345? """ ) result = PostgresEngineSpec.extract_errors(Exception(msg)) assert result == [ SupersetError( error_type=SupersetErrorType.TEST_CONNECTION_HOST_DOWN_ERROR, message=( "The host 93.184.216.34 might be down, " "and can't be reached on port 12345" ), level=ErrorLevel.ERROR, extra={"engine_name": "PostgreSQL"}, ) ]
Like this one? From your PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Postgres I tested with both a hostname and an IP, and made sure the regex captured both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments.
Either the username or the password used are incorrect. | ||
``` | ||
|
||
The user provided a password that is incorrect. Please check that the | ||
password is typed correctly. | ||
Either the username provided does not exist or the password was written incorrectly. Please | ||
check that the username and were typed correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged issue 1013 already, so your PR is trying to replace it. You need to use 1014 now.
superset/db_engine_specs/mysql.py
Outdated
INVALID_ACCESS_REGEX: ( | ||
__('Either the username "%(username)s" or the password is incorrect.'), | ||
SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the regex to ACCESS_DENIED_REGEX
, to be consistent with the other errors.
superset/db_engine_specs/mysql.py
Outdated
SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR, | ||
), | ||
INVALID_HOSTNAME_REGEX: ( | ||
__('Unknown MySQL server host "%(hostname)s"'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Period here as well.
superset/db_engine_specs/mysql.py
Outdated
__('Unknown MySQL server host "%(hostname)s"'), | ||
SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, | ||
), | ||
CONNECTION_HOST_DOWN_REGEX: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's call this just HOST_DOWN_REGEX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just saw that this already existed, sorry.
But I think we should call this TEST_CONNECTION_HOST_DOWN_REGEX
, to match the error type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use that pattern as we add regexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense
superset/errors.py
Outdated
@@ -164,14 +165,13 @@ class SupersetErrorType(str, Enum): | |||
), | |||
}, | |||
], | |||
SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR: [ | |||
SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing, your PR is trying to override an existing error. You need to change this to 1014 and add it below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be fixed.
tests/db_engine_specs/mysql_tests.py
Outdated
) | ||
] | ||
|
||
msg = "mysql: Can't connect to MySQL server on 'badconnection.com'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Postgres I tested with both a hostname and an IP, and made sure the regex captured both.
Codecov Report
@@ Coverage Diff @@
## master #14089 +/- ##
==========================================
+ Coverage 79.48% 79.81% +0.33%
==========================================
Files 939 942 +3
Lines 47587 47716 +129
Branches 5949 6009 +60
==========================================
+ Hits 37823 38083 +260
+ Misses 9642 9512 -130
+ Partials 122 121 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
## Issue 1014 | ||
|
||
``` | ||
The password provided when connecting to a database is not valid. | ||
Either the username or the password used are incorrect. | ||
``` | ||
|
||
The user provided a password that is incorrect. Please check that the | ||
password is 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still overwriting an existing issue.
superset/errors.py
Outdated
@@ -164,14 +165,13 @@ class SupersetErrorType(str, Enum): | |||
), | |||
}, | |||
], | |||
SupersetErrorType.TEST_CONNECTION_INVALID_PASSWORD_ERROR: [ | |||
SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs to be fixed.
superset/db_engine_specs/mysql.py
Outdated
SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR, | ||
), | ||
TEST_CONNECTION_HOST_DOWN_REGEX: ( | ||
__("The host %(hostname)s might be down and can't be reached."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be consistent and always quote the hostname (I need to do the same on my PR for MSSQL).
5f42af2
to
9f922cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
SUMMARY
Capture the most common error messages in MySQL, and return them to the user. This is used when first making a DB.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TEST PLAN
Created unit tests
ADDITIONAL INFORMATION