Fixed scan errors

This commit is contained in:
alexjanousekGSA
2025-06-02 10:44:42 -04:00
parent 07195ba145
commit c8eae375f4
2 changed files with 17 additions and 4 deletions

View File

@@ -63,8 +63,14 @@ def get_notification_by_id(notification_id):
if hasattr(template, "subject"):
try:
notification.__dict__["subject"] = template.subject
except Exception:
pass # in case subject is a read-only property
except AttributeError as e:
current_app.logger.warning(
f"Could not set subject on notification: {e}"
)
except Exception as e:
current_app.logger.error(
f"Unexpected error setting notification subject: {e}"
)
schema = PublicNotificationResponseSchema()
schema.context = {"notification_instance": notification}

View File

@@ -1,6 +1,7 @@
from datetime import datetime, timezone
from uuid import UUID
from flask import current_app
from marshmallow import EXCLUDE, Schema, fields, post_dump
@@ -122,7 +123,13 @@ class PublicNotificationResponseSchema(PublicNotificationSchema):
elif notification and hasattr(notification, "subject"):
try:
data["subject"] = str(notification.subject)
except Exception:
pass
except AttributeError:
data["subject"] = ""
current_app.logger.debug("Notification has no subject attribute")
except Exception as e:
data["subject"] = ""
current_app.logger.warning(
f"Error getting notification subject: {e}"
)
return data