fix(scanner): confirm orphan candidates against the servers before declining - #3399
fix(scanner): confirm orphan candidates against the servers before declining#3399fallenbagel wants to merge 1 commit into
Conversation
…clining The arr scanners snapshot the library once per run and then decline any PROCESSING request missing from the snapshot, so a request created mid-scan gets declined minutes after the *arr accepted it. The stock schedule makes it routine, as both scan jobs land on a plex-wtachlist-sync tick as well. Now they are re-checked against the live servers before anything is declined, using the library-filtered endpoints.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis change adds Radarr and Sonarr library lookups by external ID. Scanner cleanup now checks matching servers before resetting processing media. Lookup failures preserve processing status. Tests cover found, failed, and missing library results. ChangesServarr orphan cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change adds server confirmation before declining orphan candidates and leaves requests untouched when confirmation is unavailable; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR prevents Radarr/Sonarr scanners from incorrectly declining in-progress requests that were added after a scan started by confirming “orphan” candidates directly against the Servarr servers before resetting status/declining requests.
Changes:
- Add per-item existence checks against Radarr/Sonarr servers before orphan cleanup proceeds (and skip cleanup if confirmation fails).
- Introduce new Radarr/Sonarr API helper methods to query library entries by TMDB/TVDB ID.
- Add unit tests covering the new cleanup behavior (recently-added items, unreachable server, true orphan).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| server/lib/scanners/sonarr/sonarr.test.ts | Adds unit tests covering orphan cleanup confirmation behavior for Sonarr. |
| server/lib/scanners/sonarr/index.ts | Adds server-confirmation step before resetting orphaned show statuses/declining requests. |
| server/lib/scanners/radarr/radarr.test.ts | Adds unit tests covering orphan cleanup confirmation behavior for Radarr. |
| server/lib/scanners/radarr/index.ts | Adds server-confirmation step before resetting orphaned movie statuses/declining requests. |
| server/api/servarr/sonarr.ts | Adds API method to query library series by TVDB ID. |
| server/api/servarr/radarr.ts | Adds API method to query library movies by TMDB ID. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Description
The Radarr and Sonarr scanners take a snapshot of the library at the start of a run and, at the end, decline any in-progress request that isn't in it. Anything requested while the scan is still running was never in that snapshot, so it gets declined a few minutes after Radarr or Sonarr already accepted it. On the default schedule, since both scan jobs fall on a watchlist sync tick and nothing stops the two running at the same time either thus this happening.
Before declining anything, the scanners now check the candidate against the servers directly instead of trusting the snapshot. If that check can't be completed the request is left alone, so a server being briefly unreachable can't decline someone's request.
How Has This Been Tested?
preview-scanner-decline-race-fix)Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit