You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/05/29 15:38:14 UTC

(superset) 01/01: chore: make DB syntax erros 400

This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch db-custom-errors-should-be-4xx
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 31330b0cf39915890b4e23b93433aae4a63d934a
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu May 29 11:38:02 2025 -0400

    chore: make DB syntax erros 400
---
 superset/commands/database/test_connection.py | 6 ++++--
 superset/commands/database/validate.py        | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/superset/commands/database/test_connection.py b/superset/commands/database/test_connection.py
index 3c16730d00..bdfec6d294 100644
--- a/superset/commands/database/test_connection.py
+++ b/superset/commands/database/test_connection.py
@@ -89,7 +89,9 @@ class TestConnectionDatabaseCommand(BaseCommand):
         self._context = context
         self._uri = uri
 
-    def run(self) -> None:  # pylint: disable=too-many-statements,too-many-branches  # noqa: C901
+    def run(
+        self,
+    ) -> None:  # pylint: disable=too-many-statements,too-many-branches  # noqa: C901
         self.validate()
         ex_str = ""
         ssh_tunnel = self._properties.get("ssh_tunnel")
@@ -188,7 +190,7 @@ class TestConnectionDatabaseCommand(BaseCommand):
             )
             # check for custom errors (wrong username, wrong password, etc)
             errors = database.db_engine_spec.extract_errors(ex, self._context)
-            raise SupersetErrorsException(errors) from ex
+            raise SupersetErrorsException(errors, status=400) from ex
         except OAuth2RedirectError:
             raise
         except SupersetSecurityException as ex:
diff --git a/superset/commands/database/validate.py b/superset/commands/database/validate.py
index eda5d75bed..41f5ce3e19 100644
--- a/superset/commands/database/validate.py
+++ b/superset/commands/database/validate.py
@@ -125,7 +125,7 @@ class ValidateDatabaseParametersCommand(BaseCommand):
                     "database": url.database,
                 }
                 errors = database.db_engine_spec.extract_errors(ex, context)
-                raise DatabaseTestConnectionFailedError(errors) from ex
+                raise DatabaseTestConnectionFailedError(errors, status=400) from ex
 
         if not alive:
             raise DatabaseOfflineError(