You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2022/10/05 16:44:57 UTC

[superset] branch master updated: chore(key-value): remove redundant exception logging (#21702)

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

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new b6891aaa9f chore(key-value): remove redundant exception logging (#21702)
b6891aaa9f is described below

commit b6891aaa9f1a5561c2b03b7c93bff6e4c401fe3c
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Oct 5 18:44:42 2022 +0200

    chore(key-value): remove redundant exception logging (#21702)
    
    Co-authored-by: Ville Brofeldt <vi...@apple.com>
---
 superset/key_value/commands/create.py         |  1 -
 superset/key_value/commands/delete.py         |  1 -
 superset/key_value/commands/delete_expired.py |  1 -
 superset/key_value/commands/get.py            |  1 -
 superset/key_value/commands/update.py         |  1 -
 superset/key_value/commands/upsert.py         | 11 +++++++----
 superset/key_value/exceptions.py              |  4 ++++
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/superset/key_value/commands/create.py b/superset/key_value/commands/create.py
index d4ab4c5c38..93e99c223b 100644
--- a/superset/key_value/commands/create.py
+++ b/superset/key_value/commands/create.py
@@ -64,7 +64,6 @@ class CreateKeyValueCommand(BaseCommand):
             return self.create()
         except SQLAlchemyError as ex:
             db.session.rollback()
-            logger.exception("Error running create command")
             raise KeyValueCreateFailedError() from ex
 
     def validate(self) -> None:
diff --git a/superset/key_value/commands/delete.py b/superset/key_value/commands/delete.py
index f8ad291714..b3cf84be07 100644
--- a/superset/key_value/commands/delete.py
+++ b/superset/key_value/commands/delete.py
@@ -50,7 +50,6 @@ class DeleteKeyValueCommand(BaseCommand):
             return self.delete()
         except SQLAlchemyError as ex:
             db.session.rollback()
-            logger.exception("Error running delete command")
             raise KeyValueDeleteFailedError() from ex
 
     def validate(self) -> None:
diff --git a/superset/key_value/commands/delete_expired.py b/superset/key_value/commands/delete_expired.py
index 4031d13968..166a9f6f87 100644
--- a/superset/key_value/commands/delete_expired.py
+++ b/superset/key_value/commands/delete_expired.py
@@ -46,7 +46,6 @@ class DeleteExpiredKeyValueCommand(BaseCommand):
             self.delete_expired()
         except SQLAlchemyError as ex:
             db.session.rollback()
-            logger.exception("Error running delete command")
             raise KeyValueDeleteFailedError() from ex
 
     def validate(self) -> None:
diff --git a/superset/key_value/commands/get.py b/superset/key_value/commands/get.py
index 01560949e3..44c02331cc 100644
--- a/superset/key_value/commands/get.py
+++ b/superset/key_value/commands/get.py
@@ -52,7 +52,6 @@ class GetKeyValueCommand(BaseCommand):
         try:
             return self.get()
         except SQLAlchemyError as ex:
-            logger.exception("Error running get command")
             raise KeyValueGetFailedError() from ex
 
     def validate(self) -> None:
diff --git a/superset/key_value/commands/update.py b/superset/key_value/commands/update.py
index 4078a0dcb6..b69ca5e70d 100644
--- a/superset/key_value/commands/update.py
+++ b/superset/key_value/commands/update.py
@@ -66,7 +66,6 @@ class UpdateKeyValueCommand(BaseCommand):
             return self.update()
         except SQLAlchemyError as ex:
             db.session.rollback()
-            logger.exception("Error running update command")
             raise KeyValueUpdateFailedError() from ex
 
     def validate(self) -> None:
diff --git a/superset/key_value/commands/upsert.py b/superset/key_value/commands/upsert.py
index 80b0255595..06b33c90fc 100644
--- a/superset/key_value/commands/upsert.py
+++ b/superset/key_value/commands/upsert.py
@@ -26,7 +26,10 @@ from sqlalchemy.exc import SQLAlchemyError
 from superset import db
 from superset.commands.base import BaseCommand
 from superset.key_value.commands.create import CreateKeyValueCommand
-from superset.key_value.exceptions import KeyValueUpdateFailedError
+from superset.key_value.exceptions import (
+    KeyValueCreateFailedError,
+    KeyValueUpsertFailedError,
+)
 from superset.key_value.models import KeyValueEntry
 from superset.key_value.types import Key, KeyValueResource
 from superset.key_value.utils import get_filter
@@ -66,10 +69,9 @@ class UpsertKeyValueCommand(BaseCommand):
     def run(self) -> Key:
         try:
             return self.upsert()
-        except SQLAlchemyError as ex:
+        except (KeyValueCreateFailedError, SQLAlchemyError) as ex:
             db.session.rollback()
-            logger.exception("Error running update command")
-            raise KeyValueUpdateFailedError() from ex
+            raise KeyValueUpsertFailedError() from ex
 
     def validate(self) -> None:
         pass
@@ -90,6 +92,7 @@ class UpsertKeyValueCommand(BaseCommand):
             db.session.merge(entry)
             db.session.commit()
             return Key(entry.id, entry.uuid)
+
         return CreateKeyValueCommand(
             resource=self.resource,
             value=self.value,
diff --git a/superset/key_value/exceptions.py b/superset/key_value/exceptions.py
index fc66d24c2f..b05daf6b89 100644
--- a/superset/key_value/exceptions.py
+++ b/superset/key_value/exceptions.py
@@ -46,5 +46,9 @@ class KeyValueUpdateFailedError(UpdateFailedError):
     message = _("An error occurred while updating the value.")
 
 
+class KeyValueUpsertFailedError(UpdateFailedError):
+    message = _("An error occurred while upserting the value.")
+
+
 class KeyValueAccessDeniedError(ForbiddenError):
     message = _("You don't have permission to modify the value.")