You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2024/02/15 17:45:27 UTC

(superset) branch diego/ch78628/fix-delete-ssh-endpoint created (now 9c5de2b555)

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

diegopucci pushed a change to branch diego/ch78628/fix-delete-ssh-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 9c5de2b555 Fix DELETE ssh_tunnel

This branch includes the following new commits:

     new 9c5de2b555 Fix DELETE ssh_tunnel

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: Fix DELETE ssh_tunnel

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch diego/ch78628/fix-delete-ssh-endpoint
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 9c5de2b555e612ef73fff69d7ff032594f1e83c6
Author: geido <di...@gmail.com>
AuthorDate: Thu Feb 15 19:45:11 2024 +0200

    Fix DELETE ssh_tunnel
---
 superset/databases/api.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/superset/databases/api.py b/superset/databases/api.py
index 62fb729437..f251b45880 100644
--- a/superset/databases/api.py
+++ b/superset/databases/api.py
@@ -1483,11 +1483,17 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
             500:
               $ref: '#/components/responses/500'
         """
-        try:
-            DeleteSSHTunnelCommand(pk).run()
-            return self.response(200, message="OK")
-        except SSHTunnelNotFoundError:
+
+        database = DatabaseDAO.find_by_id(pk)
+        if not database:
             return self.response_404()
+        try:
+            existing_ssh_tunnel_model = database.ssh_tunnels
+            if existing_ssh_tunnel_model:
+                DeleteSSHTunnelCommand(existing_ssh_tunnel_model.id).run()
+                return self.response(200, message="OK")
+            else:
+                return self.response_404()
         except SSHTunnelDeleteFailedError as ex:
             logger.error(
                 "Error deleting SSH Tunnel %s: %s",