From 13da2ddbf1886f1cf6def6e417178acc39026e47 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 14 Aug 2026 23:51:15 +0000 Subject: [PATCH] fix: use valid notification fallback log level Co-authored-by: jokob-sk <96159884+jokob-sk@users.noreply.github.com> --- .github/skills/code-standards/SKILL.md | 1 + server/models/notification_instance.py | 2 +- test/backend/test_notification_templates.py | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/skills/code-standards/SKILL.md b/.github/skills/code-standards/SKILL.md index 83c52d0a8..e1f299bdf 100644 --- a/.github/skills/code-standards/SKILL.md +++ b/.github/skills/code-standards/SKILL.md @@ -24,6 +24,7 @@ description: NetAlertX coding standards and conventions. Use this when writing c - follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs - all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation - no inline imports, all imports must be at the top of the file +- when using `server/logger.py` `mylog()`, only use valid levels: `none`, `minimal`, `verbose`, `debug`, `trace`; invalid levels silently degrade to `none` ## File Length diff --git a/server/models/notification_instance.py b/server/models/notification_instance.py index 2f78e9877..45327659f 100755 --- a/server/models/notification_instance.py +++ b/server/models/notification_instance.py @@ -421,7 +421,7 @@ def finalize_html(mail_html, preheaders): ) except XMLTokenError as err: mylog( - "warn", + "none", f"[Notification] Failed to pretty-print HTML report, sending unindented HTML instead: {err}", ) return mail_html diff --git a/test/backend/test_notification_templates.py b/test/backend/test_notification_templates.py index 6f36c5cfd..a21e6ece7 100644 --- a/test/backend/test_notification_templates.py +++ b/test/backend/test_notification_templates.py @@ -334,8 +334,9 @@ class TestConstructNotificationsTemplates(unittest.TestCase): # ----------------------------------------------------------------- # Final HTML escapes preheaders and tolerates indent failures # ----------------------------------------------------------------- + @patch("models.notification_instance.mylog") @patch("models.notification_instance.indent") - def test_finalize_html_escapes_preheader_and_falls_back(self, mock_indent): + def test_finalize_html_escapes_preheader_and_falls_back(self, mock_indent, mock_mylog): from models.notification_instance import finalize_html, XMLTokenError mock_indent.side_effect = XMLTokenError("broken html") @@ -351,6 +352,10 @@ class TestConstructNotificationsTemplates(unittest.TestCase): self.assertEqual(final_html, expected_html) mock_indent.assert_called_once() + mock_mylog.assert_called_once_with( + "none", + "[Notification] Failed to pretty-print HTML report, sending unindented HTML instead: broken html", + ) if __name__ == "__main__":