From 8e396f957fb13e847cc9909be1fd46a7ee3109cc Mon Sep 17 00:00:00 2001 From: martino <32328813+f3rs3n@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:04:53 +0200 Subject: [PATCH] fix(notifications): avoid repeating subject causes already in error diagnostics --- .../tests/test_notification_maintainer_followup.py | 8 ++++++++ AppImage/scripts/notification_templates.py | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/scripts/tests/test_notification_maintainer_followup.py b/.github/scripts/tests/test_notification_maintainer_followup.py index 42d37377..74bfc2b9 100644 --- a/.github/scripts/tests/test_notification_maintainer_followup.py +++ b/.github/scripts/tests/test_notification_maintainer_followup.py @@ -129,6 +129,14 @@ class MaintainerFollowupTests(unittest.TestCase): self.assertIn('white-space:pre-wrap;',result['html']) self.assertNotIn(templates.runtime_message('digest.footer',lang),result['body']) + def test_concrete_subject_cause_already_in_error_log_is_not_repeated(self): + event=receive(NATIVE_REPORT+'\n100: ERROR: job-end hook denied','error', + 'vzdump backup status (raw-host): backup failed: job-end hook denied') + for lang in LANGUAGES: + result=deliver(event.event_type,event.data,event.severity,lang) + self.assertEqual(result['text'].count('job-end hook denied'),1) + self.assertIn('100: ERROR: job-end hook denied',result['body']) + def test_job_level_subject_cause_survives_warning_cap(self): raw=NATIVE_REPORT+'\n'+'\n'.join('WARN: repeated diagnostic '+str(i) for i in range(80)) event=receive(raw,'error','vzdump backup status (raw-host): backup failed: job-end hook denied') diff --git a/AppImage/scripts/notification_templates.py b/AppImage/scripts/notification_templates.py index 6bb5f513..99ae05ff 100644 --- a/AppImage/scripts/notification_templates.py +++ b/AppImage/scripts/notification_templates.py @@ -2189,7 +2189,11 @@ def render_template(event_type: str, data: Dict[str, Any], source_subject = cause.group(1).strip() if cause else '' if source_subject.lower() == 'multiple problems': source_subject = '' - if source_subject and source_subject not in body_text: + cause_in_diagnostics = any( + line.strip() == source_subject or + re.split(r'\b(?:TASK ERROR:|ERROR:)\s*', line, maxsplit=1, flags=re.IGNORECASE)[-1].strip() == source_subject + for line in backup_diagnostics) + if source_subject and source_subject not in body_text and not cause_in_diagnostics: # A unique job/setup cause must survive a warning-heavy report. backup_diagnostics.insert(0, source_subject)