|
| 1 | +--- |
| 2 | +id: TASK-292 |
| 3 | +title: Fix watcher error path dropping new tracks instead of proceeding unfiltered |
| 4 | +status: To Do |
| 5 | +assignee: [] |
| 6 | +created_date: '2026-02-26 00:10' |
| 7 | +labels: |
| 8 | + - bug |
| 9 | + - roborev |
| 10 | +dependencies: [] |
| 11 | +references: |
| 12 | + - crates/mt-tauri/src/watcher.rs |
| 13 | + - crates/mt-tauri/src/db/removed.rs |
| 14 | + - 'roborev job #29' |
| 15 | +priority: high |
| 16 | +--- |
| 17 | + |
| 18 | +## Description |
| 19 | + |
| 20 | +<!-- SECTION:DESCRIPTION:BEGIN --> |
| 21 | +Roborev review job #29 (commit 1a70d1a) found issues in the watcher's removed-tracks filtering error handling. |
| 22 | + |
| 23 | +**High severity**: When `filter_removed_tracks` fails, the inner error path returns `vec![]` — dropping all new tracks instead of proceeding unfiltered as documented. The comment says "fall back to unfiltered insertion so new tracks aren't lost" but the code does the opposite. This is a regression from the pre-refactor behavior where `truly_new` was returned on query errors. |
| 24 | + |
| 25 | +Root cause: `filter_removed_tracks` takes ownership of the vec, so it's unavailable on error. |
| 26 | + |
| 27 | +**Low severity**: The error log message says "proceeding unfiltered" but the code returns an empty vec. The message should match actual behavior. |
| 28 | + |
| 29 | +### Fix options (from review) |
| 30 | + |
| 31 | +1. Change `filter_removed_tracks` signature to return the original vec inside the error (e.g., `Result<(Vec<T>, usize), (DbError, Vec<T>)>`). Cleanest — no clone on happy path. |
| 32 | +2. Clone before calling: `let fallback = truly_new.clone();` and return `fallback` on error. Simple but wastes allocation on happy path. |
| 33 | +3. Have `filter_removed_tracks` take `&[T]` and return a new vec rather than consuming the input. |
| 34 | + |
| 35 | +### Source |
| 36 | + |
| 37 | +- roborev job #29, verdict: FAIL |
| 38 | +- File: `crates/mt-tauri/src/watcher.rs` ~line 638 |
| 39 | +- File: `crates/mt-tauri/src/db/removed.rs` (`filter_removed_tracks` signature) |
| 40 | +<!-- SECTION:DESCRIPTION:END --> |
| 41 | + |
| 42 | +## Acceptance Criteria |
| 43 | +<!-- AC:BEGIN --> |
| 44 | +- [ ] #1 When filter_removed_tracks fails, watcher falls back to unfiltered insertion (returns all new tracks, not empty vec) |
| 45 | +- [ ] #2 Error log message accurately describes actual behavior |
| 46 | +- [ ] #3 Existing tests continue to pass |
| 47 | +- [ ] #4 No unnecessary clone on the happy path (prefer option 1 or 3) |
| 48 | +<!-- AC:END --> |
0 commit comments