Gracefully handle decryption errors in past-7-days notification reports

This commit is contained in:
Ryan Ahearn
2022-12-13 14:18:34 -05:00
parent e639ce2fba
commit 431f7aeb3c
2 changed files with 14 additions and 1 deletions

View File

@@ -3,6 +3,9 @@ import itertools
import uuid
from flask import current_app, url_for
from notifications_utils.clients.encryption.encryption_client import (
EncryptionError,
)
from notifications_utils.insensitive_dict import InsensitiveDict
from notifications_utils.letter_timings import get_letter_timings
from notifications_utils.postal_address import (
@@ -1512,7 +1515,10 @@ class Notification(db.Model):
@property
def personalisation(self):
if self._personalisation:
return encryption.decrypt(self._personalisation)
try:
return encryption.decrypt(self._personalisation)
except EncryptionError:
current_app.logger.error("Error decrypting notification.personalisation, returning empty dict")
return {}
@personalisation.setter