This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 60c2a3bf82 Refactor and fix AWS secret manager invalid exception
(#24898)
60c2a3bf82 is described below
commit 60c2a3bf82b4fe923b8006f6694f74823af87537
Author: GitStart-AirFlow <[email protected]>
AuthorDate: Fri Jul 8 15:21:42 2022 +0100
Refactor and fix AWS secret manager invalid exception (#24898)
---
.../amazon/aws/secrets/secrets_manager.py | 32 ++++++++++++++++++----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/airflow/providers/amazon/aws/secrets/secrets_manager.py
b/airflow/providers/amazon/aws/secrets/secrets_manager.py
index 0ee73bc330..047772ea1d 100644
--- a/airflow/providers/amazon/aws/secrets/secrets_manager.py
+++ b/airflow/providers/amazon/aws/secrets/secrets_manager.py
@@ -245,6 +245,7 @@ class SecretsManagerBackend(BaseSecretsBackend,
LoggingMixin):
:param path_prefix: Prefix for the Path to get Secret
:param secret_id: Secret Key
"""
+ error_msg = "An error occurred when calling the get_secret_value
operation"
if path_prefix:
secrets_path = self.build_path(path_prefix, secret_id, self.sep)
else:
@@ -257,15 +258,36 @@ class SecretsManagerBackend(BaseSecretsBackend,
LoggingMixin):
return response.get('SecretString')
except self.client.exceptions.ResourceNotFoundException:
self.log.debug(
- "An error occurred (ResourceNotFoundException) when calling
the "
- "get_secret_value operation: "
- "Secret %s not found.",
+ "ResourceNotFoundException: %s. Secret %s not found.",
+ error_msg,
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",
+ "InvalidParameterException: %s",
+ error_msg,
+ exc_info=True,
+ )
+ return None
+ except self.client.exceptions.InvalidRequestException:
+ self.log.debug(
+ "InvalidRequestException: %s",
+ error_msg,
+ exc_info=True,
+ )
+ return None
+ except self.client.exceptions.DecryptionFailure:
+ self.log.debug(
+ "DecryptionFailure: %s",
+ error_msg,
+ exc_info=True,
+ )
+ return None
+ except self.client.exceptions.InternalServiceError:
+ self.log.debug(
+ "InternalServiceError: %s",
+ error_msg,
exc_info=True,
)
return None