You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/04/12 22:07:54 UTC

[GitHub] [superset] betodealmeida commented on a change in pull request #14089: feat: invalid hostname and password error messages (MySQL)

betodealmeida commented on a change in pull request #14089:
URL: https://github.com/apache/superset/pull/14089#discussion_r611984606



##########
File path: superset-frontend/package-lock.json
##########
@@ -1,8 +1,9 @@
 {
   "name": "superset",
   "version": "0.999.0dev",
-  "lockfileVersion": 2,
+  "lockfileVersion": 1,
   "requires": true,
+<<<<<<< HEAD

Review comment:
       We don't want to update this file in a PR involving just the backend. You can rever this with:
   
   ```bash
   $ git checkout master -- superset-frontend/package-lock.json
   ```

##########
File path: superset/db_engine_specs/mysql.py
##########
@@ -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'),

Review comment:
       "... or **the** password is incorrect." would be better?
   
   Also, all messages should end in a period.

##########
File path: superset/errors.py
##########
@@ -164,6 +165,7 @@ class SupersetErrorType(str, Enum):
             ),
         },
     ],
+<<<<<<< HEAD

Review comment:
       Fix fix

##########
File path: docs/src/pages/docs/Miscellaneous/issue_codes.mdx
##########
@@ -144,8 +144,16 @@ that the username is typed correctly and exists in the database.
 ## Issue 1013
 
 ```
+<<<<<<< HEAD

Review comment:
       Fix this merge conflict?

##########
File path: tests/db_engine_specs/mysql_tests.py
##########
@@ -104,3 +105,64 @@ def test_extract_error_message(self):
         exception = OperationalError(123, message)
         extracted_message = MySQLEngineSpec._extract_error_message(exception)
         assert extracted_message == message
+
+    def test_extract_errors(self):
+        """
+        Test that custom error messages are extracted correctly.
+        """
+        msg = "mysql: Access denied for user 'test'@'testuser.com' "
+        result = MySQLEngineSpec.extract_errors(Exception(msg))
+        assert result == [
+            SupersetError(
+                error_type=SupersetErrorType.TEST_CONNECTION_ACCESS_DENIED_ERROR,
+                message='Either the username "test" or password is incorrect',
+                level=ErrorLevel.ERROR,
+                extra={
+                    "engine_name": "MySQL",
+                    "issue_codes": [
+                        {
+                            "code": 1013,
+                            "message": "Issue 1013 - Either the username or the password is wrong.",
+                        }
+                    ],
+                },
+            )
+        ]
+
+        msg = "mysql: Unknown MySQL server host 'badhostname.com' "
+        result = MySQLEngineSpec.extract_errors(Exception(msg))
+        assert result == [
+            SupersetError(
+                error_type=SupersetErrorType.TEST_CONNECTION_INVALID_HOSTNAME_ERROR,
+                message='Unknown MySQL server host "badhostname.com"',
+                level=ErrorLevel.ERROR,
+                extra={
+                    "engine_name": "MySQL",
+                    "issue_codes": [
+                        {
+                            "code": 1007,
+                            "message": "Issue 1007 - The hostname provided can't be resolved.",
+                        }
+                    ],
+                },
+            )
+        ]
+
+        msg = "mysql: Can't connect to MySQL server on 'badconnection.com'"

Review comment:
       Can you try also with an IP address instead of a name? To see if the message is similar and still gets captured?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org