From dd562dc6ea2587130643dc7dac21daa0b35cea7e Mon Sep 17 00:00:00 2001 From: Kyle MacMillan <16893311+k-macmillan@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:28:50 -0400 Subject: [PATCH] HOTFIX - Changed error to warning for retryable failures (#1894) --- .pre-commit-config.yaml | 6 +++--- .../vetext_incoming_forwarder_lambda.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65d5a5dce3..da811414e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ repos: - repo: https://github.com/thoughtworks/talisman - rev: 'v1.31.0' + rev: 'v1.32.0' hooks: - id: talisman-commit entry: cmd --githook pre-commit - repo: https://github.com/PyCQA/bandit - rev: '1.7.8' + rev: '1.7.9' hooks: - id: bandit args: [-c, .bandit.yml, -r, -l] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.3.3' + rev: 'v0.5.5' hooks: # Run the linter. - id: ruff diff --git a/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py b/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py index d7f194a214..cf015377b5 100644 --- a/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py +++ b/lambda_functions/vetext_incoming_forwarder_lambda/vetext_incoming_forwarder_lambda.py @@ -30,7 +30,7 @@ TWILIO_PH_AUTH_TOKEN_SSM_NAME = os.getenv('TWILIO_PH_AUTH_TOKEN_SSM_NAME') LOG_ENCRYPTION_SSM_NAME = os.getenv('LOG_ENCRYPTION_SSM_NAME') -if TWILIO_AUTH_TOKEN_SSM_NAME is None or TWILIO_AUTH_TOKEN_SSM_NAME == 'DEFAULT' or LOG_ENCRYPTION_SSM_NAME is None: +if TWILIO_AUTH_TOKEN_SSM_NAME is None or TWILIO_AUTH_TOKEN_SSM_NAME == 'DEFAULT' or LOG_ENCRYPTION_SSM_NAME is None: # nosec sys.exit('A required environment variable is not set. Please ensure all env variables are set') TWILIO_VETEXT_PATH = '/twoway/vettext' @@ -72,7 +72,7 @@ def get_twilio_tokens(): @return: List of Twilio auth tokens from SSM """ try: - if TWILIO_AUTH_TOKEN_SSM_NAME == 'unit_test' or TWILIO_PH_AUTH_TOKEN_SSM_NAME == 'unit_test': + if TWILIO_AUTH_TOKEN_SSM_NAME == 'unit_test' or TWILIO_PH_AUTH_TOKEN_SSM_NAME == 'unit_test': # nosec # item 0 was the auth token used to sign the body of the request return ['bad_twilio_auth', 'invalid_auth', 'unit_test'] @@ -279,7 +279,7 @@ def read_from_ssm(key: str) -> str: return response.get('Parameter', {}).get('Value') -def make_vetext_request(request_body): +def make_vetext_request(request_body): # noqa: C901 (too complex 13 > 10) endpoint = request_body.get('path', TWILIO_VETEXT_PATH) logger.debug('Making VeText Request for endpoint: %s', endpoint) @@ -343,7 +343,7 @@ def make_vetext_request(request_body): logger.debug('json dumps: %s', json.dumps(body)) try: - response = requests.post(endpoint_uri, verify=False, json=body, timeout=HTTPTIMEOUT, headers=headers) + response = requests.post(endpoint_uri, verify=False, json=body, timeout=HTTPTIMEOUT, headers=headers) # nosec logger.info('VeText POST complete') response.raise_for_status() @@ -353,11 +353,13 @@ def make_vetext_request(request_body): except requests.HTTPError as e: logged_body = body.copy() logged_body['body'] = 'redacted' - logger.error('HTTPError With Call To VeText url: %s, with body: %s and error: %s', endpoint_uri, logged_body, e) + logger.warning( + 'HTTPError With Call To VeText url: %s, with body: %s and error: %s', endpoint_uri, logged_body, e + ) except requests.RequestException as e: logged_body = body.copy() logged_body['body'] = 'redacted' - logger.error( + logger.warning( 'RequestException With Call To VeText url: %s, with body: %s and error: %s', endpoint_uri, logged_body,