Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing IntegrityError problems, again. #1504

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,9 +213,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:
Expand Down Expand Up @@ -244,11 +241,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."
ccostino marked this conversation as resolved.
Show resolved Hide resolved
)
# 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
Expand Down
Loading