You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/10 03:54:56 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #20727: Travix : Exception improvement on connection pagination.

uranusjr commented on a change in pull request #20727:
URL: https://github.com/apache/airflow/pull/20727#discussion_r780881315



##########
File path: airflow/models/connection.py
##########
@@ -233,7 +233,14 @@ def get_password(self) -> Optional[str]:
                     f"Can't decrypt encrypted password for login={self.login}  "
                     f"FERNET_KEY configuration is missing"
                 )
-            return fernet.decrypt(bytes(self._password, 'utf-8')).decode()
+            try:
+                decrypted_password = fernet.decrypt(bytes(self._password, 'utf-8')).decode()
+                return decrypted_password
+            except Exception as e:
+                log.exception(str(e))

Review comment:
       Do not do this.
   
   https://docs.python.org/3/library/logging.html#logging.exception
   
   > `logging.exception(msg, *args, **kwargs)`
   >
   > Logs a message with level `ERROR` on the root logger. The arguments are interpreted as for `debug()`. Exception info is added to the logging message. This function should only be called from an exception handler.
   
   So this logs the exception message_twice`, once because `exception()` adds it, once because you pass it. You should pass a user-friendly message instead, and let `exception()` log the exception for you.
   




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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