From 702127207513a4d9d312aa9b2610aa304390a51f Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Wed, 16 Apr 2025 19:10:57 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F(backend)=20remove=20perso?= =?UTF-8?q?nal=20data=20from=20email=20failure=20logs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix code that accidentally exposed personal email addresses in logs during email sending failures. Modify logging to remove identifying information to protect user privacy while still providing useful debugging context. Original code was inspired by Docs. --- src/backend/core/recording/event/notification.py | 2 +- src/backend/core/tests/recording/event/test_notification.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/core/recording/event/notification.py b/src/backend/core/recording/event/notification.py index 617ea06d..9c01c270 100644 --- a/src/backend/core/recording/event/notification.py +++ b/src/backend/core/recording/event/notification.py @@ -83,7 +83,7 @@ class NotificationService: fail_silently=False, ) except smtplib.SMTPException as exception: - logger.error("notification to %s was not sent: %s", emails, exception) + logger.error("notification could not be sent: %s", exception) return False return True diff --git a/src/backend/core/tests/recording/event/test_notification.py b/src/backend/core/tests/recording/event/test_notification.py index 0fd8dcc7..7c56af53 100644 --- a/src/backend/core/tests/recording/event/test_notification.py +++ b/src/backend/core/tests/recording/event/test_notification.py @@ -150,9 +150,9 @@ def test_notify_user_by_email_smtp_exception(mocked_current_site, caplog): """Test email notification when an exception occurs.""" recording = factories.RecordingFactory(room__name="Conference Room A") - owner = factories.UserRecordingAccessFactory( + factories.UserRecordingAccessFactory( recording=recording, role=models.RoleChoices.OWNER - ).user + ) notification_service = NotificationService() @@ -164,4 +164,4 @@ def test_notify_user_by_email_smtp_exception(mocked_current_site, caplog): assert result is False mock_send_mail.assert_called_once() - assert f"notification to ['{owner.email}'] was not sent" in caplog.text + assert "notification could not be sent:" in caplog.text