From 6468cbbc7433b807b93da4cadb6ced64d64cb723 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Fri, 13 Feb 2026 10:52:00 +0100 Subject: [PATCH] Fix Autotask and internal tickets not linking to missed runs Added ticket linking to missed runs by calling link_open_internal_tickets_to_run after creating missed JobRun records in _ensure_missed_runs_for_job function. Changes: - Added import for link_open_internal_tickets_to_run in routes_run_checks.py - Added db.session.flush() and ticket linking call after creating weekly missed runs - Added db.session.flush() and ticket linking call after creating monthly missed runs - Ensures missed runs receive same ticket propagation as email-based runs This fixes the issue where missed runs were not showing linked internal tickets or Autotask tickets, while error/warning runs from emails were working correctly. Co-Authored-By: Claude Sonnet 4.5 --- .../backupchecks/src/backend/app/main/routes_run_checks.py | 5 +++++ docs/changelog-claude.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/containers/backupchecks/src/backend/app/main/routes_run_checks.py b/containers/backupchecks/src/backend/app/main/routes_run_checks.py index 71b7fbe..8c5cee9 100644 --- a/containers/backupchecks/src/backend/app/main/routes_run_checks.py +++ b/containers/backupchecks/src/backend/app/main/routes_run_checks.py @@ -38,6 +38,7 @@ from ..models import ( TicketScope, User, ) +from ..ticketing_utils import link_open_internal_tickets_to_run AUTOTASK_TERMINAL_STATUS_IDS = {5} @@ -725,6 +726,8 @@ def _ensure_missed_runs_for_job(job: Job, start_from: date, end_inclusive: date) mail_message_id=None, ) db.session.add(miss) + db.session.flush() # Ensure miss.id is available for ticket linking + link_open_internal_tickets_to_run(run=miss, job=job) inserted += 1 d = d + timedelta(days=1) @@ -806,6 +809,8 @@ def _ensure_missed_runs_for_job(job: Job, start_from: date, end_inclusive: date) mail_message_id=None, ) db.session.add(miss) + db.session.flush() # Ensure miss.id is available for ticket linking + link_open_internal_tickets_to_run(run=miss, job=job) inserted += 1 # Next month diff --git a/docs/changelog-claude.md b/docs/changelog-claude.md index d18ea83..551734c 100644 --- a/docs/changelog-claude.md +++ b/docs/changelog-claude.md @@ -5,7 +5,7 @@ This file documents all changes made to this project via Claude Code. ## [2026-02-13] ### Fixed -- Fixed Autotask internal tickets not being linked to new runs (issue from 2026-02-11 now resolved) +- Fixed Autotask tickets and internal tickets not being linked to missed runs by calling `link_open_internal_tickets_to_run` after creating missed JobRun records in `_ensure_missed_runs_for_job` (both weekly and monthly schedules), ensuring missed runs now receive the same ticket propagation as email-based runs ## [2026-02-12]