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/07/07 16:08:21 UTC

[GitHub] [airflow] josh-fell commented on a diff in pull request #24898: Refactor and fix AWS secret manager invalid exception

josh-fell commented on code in PR #24898:
URL: https://github.com/apache/airflow/pull/24898#discussion_r916049648


##########
airflow/providers/amazon/aws/secrets/secrets_manager.py:
##########
@@ -257,15 +258,32 @@ def _get_secret(self, path_prefix, secret_id: str) -> Optional[str]:
             return response.get('SecretString')
         except self.client.exceptions.ResourceNotFoundException:
             self.log.debug(
-                "An error occurred (ResourceNotFoundException) when calling the "
-                "get_secret_value operation: "
+                f"ResourceNotFoundException: {error_msg}: "
                 "Secret %s not found.",
                 secret_id,
             )
             return None
-        except self.client.exceptions.AccessDeniedException:
+        except self.client.exceptions.InvalidParameterException:
             self.log.debug(
-                "An error occurred (AccessDeniedException) when calling the get_secret_value operation",
+                f"InvalidParameterException: {error_msg}",
+                exc_info=True,
+            )
+            return None
+        except self.client.exceptions.InvalidRequestException:
+            self.log.debug(
+                f"InvalidRequestException: {error_msg}",

Review Comment:
   Can you change the the logging statements to use %-formatting instead of f-strings please? This makes sure that the string formatting is deferred until it cannot be avoided. [This is a helpful reference](https://blog.pilosus.org/posts/2020/01/24/python-f-strings-in-logging/) which hopefully explains the practice here.



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