notification: Handle more formatting errors

When there message strings containing substrings of the form
"{object.property}", an AttributeError is raised instead of KeyError during
string formatting. Catch these errors.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-04-17 18:33:11 -07:00 committed by James Valleroy
parent 5c101a1447
commit 685e636a93
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -292,7 +292,7 @@ class Notification(models.StoredNotification):
string_ = str(string_)
if data:
string_ = SafeFormatter().vformat(string_, [], data)
except KeyError as error:
except (KeyError, AttributeError) as error:
logger.warning(
'Notification missing required key during translation: %s',
error)