mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-15 17:52:26 -05:00
Downgrade log level for missing notifications in SES receipt
The timestamps available in the SES receipt don't always correspond to the time the notification has been sent. We've seen callbacks with a current timestamp in both 'mail' and 'bounce' objects that referenced a notification sent a week ago, which means we can't rely on it to skip archived notifications. One possible approach would be to look up the notification reference in the notification_history table, but this goes against our plans to stop relying on it in the future. This changes the SES receipts logic to retry missing notifications once (if the callback timestamp is within the last 5 minutes the task will retry after a 5 minute delay) to capture callbacks arriving before the notification reference has been persisted to the DB. Otherwise, we log the missing notification as a warning instead of error.
This commit is contained in:
@@ -42,10 +42,10 @@ def process_ses_results(self, response):
|
||||
notification = notifications_dao.dao_get_notification_by_reference(reference)
|
||||
except NoResultFound:
|
||||
message_time = iso8601.parse_date(ses_message['mail']['timestamp']).replace(tzinfo=None)
|
||||
if datetime.utcnow() - message_time < timedelta(minutes=10):
|
||||
if datetime.utcnow() - message_time < timedelta(minutes=5):
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
elif datetime.utcnow() - message_time < timedelta(days=3):
|
||||
current_app.logger.error(
|
||||
else:
|
||||
current_app.logger.warning(
|
||||
"notification not found for reference: {} (update to {})".format(reference, notification_status)
|
||||
)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user