Skip to content

fix(safety): skip libraries with empty watch history instead of treating all items as unwatched - #298

Open
rfsbraz wants to merge 5 commits into
mainfrom
fix/empty-watch-history-guard
Open

fix(safety): skip libraries with empty watch history instead of treating all items as unwatched#298
rfsbraz wants to merge 5 commits into
mainfrom
fix/empty-watch-history-guard

Conversation

@rfsbraz

@rfsbraz rfsbraz commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Fixes #287

Stacked on #297 (which stacks on #283) - merge in that order.

  • An empty Tautulli activity set made find_watched_data return None for every item, bypassing last_watched_threshold and the watch_status: unwatched check - one degraded Tautulli response (DB rebuild, section ID mismatch, empty auth result) could mass-delete recently watched content, up to max_actions_per_run per library
  • New guard: when a library has items, uses watch-based rules in the dangerous direction (unwatched, last_watched_threshold, apply_last_watch_threshold_to_collections), and Tautulli returns zero activity, the library is skipped for the run with a loud error via the existing fail-safe handler
  • watch_status: watched needs no guard (empty data already fails safe: nothing matches, nothing is deleted); libraries without watch rules are unaffected
  • Genuinely never-watched libraries can opt out with allow_empty_watch_history: true (added to the schema, so the generated configuration reference picks it up); the opt-out logs a warning each run
  • Tests cover both trigger rules, all four pass-through cases, the opt-out, and the deleterr-level skip (library counted failed, zero deletions)

The "activity far below previous run" degradation heuristic from #287 needs state plumbing into MediaCleaner and has real false-positive scenarios (deliberate Tautulli history cleanup), so this PR covers the empty case; partial-history hardening ties into #289's pagination guard.

@sonarqubecloud

sonarqubecloud Bot commented Jul 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty or degraded Tautulli watch history can mass-delete watched content

1 participant