From 2ebe7d8aed28c838adf08a2de8a92b45b75dda44 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Thu, 12 Mar 2026 14:44:44 +0100 Subject: [PATCH] Exclude archived jobs from auto mail matching --- containers/backupchecks/src/backend/app/job_matching.py | 7 +++++++ docs/changelog-claude.md | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/containers/backupchecks/src/backend/app/job_matching.py b/containers/backupchecks/src/backend/app/job_matching.py index 6d95708..3c56b59 100644 --- a/containers/backupchecks/src/backend/app/job_matching.py +++ b/containers/backupchecks/src/backend/app/job_matching.py @@ -35,6 +35,11 @@ def find_matching_job(msg: MailMessage) -> Optional[Job]: q = Job.query + # Never auto-match archived jobs. + # Archived jobs should remain historical and must not receive new mail links/runs. + if hasattr(Job, "archived"): + q = q.filter(Job.archived.is_(False)) + if norm_from is None: q = q.filter(Job.from_address.is_(None)) else: @@ -86,6 +91,8 @@ def find_matching_job(msg: MailMessage) -> Optional[Job]: return None q2 = Job.query + if hasattr(Job, "archived"): + q2 = q2.filter(Job.archived.is_(False)) if norm_from is None: q2 = q2.filter(Job.from_address.is_(None)) else: diff --git a/docs/changelog-claude.md b/docs/changelog-claude.md index c88bab4..35474b4 100644 --- a/docs/changelog-claude.md +++ b/docs/changelog-claude.md @@ -2,6 +2,14 @@ This file documents all changes made to this project via Claude Code. +## [2026-03-12] + +### Fixed +- Prevented automatic mail-to-job matching from selecting archived jobs: + - Updated `app/job_matching.py` so `find_matching_job()` excludes `jobs.archived = true`. + - Applied the same archived filter in the VSPC normalized fallback match path. + - This prevents new imports/re-parse auto-approval from attaching messages/runs to archived jobs. + ## [2026-03-02] ### Fixed