From f1e8ff3328e3868becc072eeaa3c907af63006d4 Mon Sep 17 00:00:00 2001 From: Cliff Hill Date: Fri, 27 Dec 2024 12:17:44 -0500 Subject: [PATCH 1/2] Fixing IntegrityError problems, again. Signed-off-by: Cliff Hill --- app/celery/tasks.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index cbb9e22b6..0e36d6c84 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -214,9 +214,7 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i f"service not allowed to send for job_id {notification.get('job', None)}, aborting" ) ) - current_app.logger.debug( - "SMS {} failed as restricted service".format(notification_id) - ) + current_app.logger.debug(f"SMS {notification_id} failed as restricted service") return try: @@ -244,11 +242,12 @@ def save_sms(self, service_id, notification_id, encrypted_notification, sender_i reply_to_text=reply_to_text, ) except IntegrityError: - if notification_exists(notification_id): - saved_notification = get_notification(notification_id) - - else: - raise + current_app.logger.warning( + f"{NotificationType.SMS}: {notification_id} already exists." + ) + # If we don't have the return statement here, we will fall through and end + # up retrying because IntegrityError is a subclass of SQLAlchemyError + return # Kick off sns process in provider_tasks.py sn = saved_notification From e2413bac76dbda6f41059f0cf01580d37129078e Mon Sep 17 00:00:00 2001 From: Cliff Hill Date: Fri, 27 Dec 2024 12:21:43 -0500 Subject: [PATCH 2/2] Flake8 fixes. Signed-off-by: Cliff Hill --- app/celery/tasks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 0e36d6c84..3743aa294 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -24,7 +24,6 @@ from app.errors import TotalRequestsError from app.notifications.process_notifications import ( get_notification, - notification_exists, persist_notification, ) from app.notifications.validators import check_service_over_total_message_limit