fix(watchlistsync): re-request deleted media from watchlist#3072
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughMediaRequest now transitions existing media marked UNKNOWN or DELETED to PENDING (including 4K variant) and excludes auto-request records tied to DELETED media. WatchlistSync treats DELETED media as unavailable and ignores deleted auto-requests when deciding which watchlist items to re-request; tests validate these behaviors. ChangesDELETED Media Re-request Handling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 fixes Plex watchlist sync and manual request behavior for media that was deleted from the backing media server by ensuring deleted media can be re-requested and stale auto-requests don’t incorrectly block new requests.
Changes:
- Exclude
DELETEDmedia from theautoRequestedTmdbIdsshort-circuit so watchlist sync can re-request deleted items. - Treat
DELETEDmovies similarly toUNKNOWNin the watchlist “unavailable” filter so they become eligible for auto-request. - Adjust
MediaRequest.request()to avoid duplicate auto-request conflicts forDELETEDmedia and to reset status back toPENDINGwhen re-requesting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
server/lib/watchlistsync.ts |
Updates watchlist gating logic to allow re-requesting DELETED media and avoid stale auto-request short-circuits. |
server/lib/watchlistsync.test.ts |
Adds an integration-style test verifying watchlist sync re-requests DELETED items while skipping non-requestable statuses. |
server/entity/MediaRequest.ts |
Updates request creation and duplicate auto-request guards to treat DELETED media as re-requestable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/entity/MediaRequest.ts`:
- Around line 162-165: The current conditional mutates media.status4k (when it
is MediaStatus.UNKNOWN or MediaStatus.DELETED) regardless of the request mode;
restrict that transition to only run for 4K requests by requiring
requestBody.is4k to be true before changing media.status4k to
MediaStatus.PENDING. Update the conditional that checks media.status4k (the
block that assigns media.status4k = MediaStatus.PENDING) to first verify
requestBody.is4k, and keep the existing checks for MediaStatus.UNKNOWN and
MediaStatus.DELETED (and the special-case for DELETED) so non-4K requests do not
alter the 4K lifecycle state.
- Around line 204-207: The duplicate auto-request guard currently checks
r.media?.status only; update it to be tier-aware by checking the appropriate
media status for 4K requests. Replace the r.media?.status !==
MediaStatus.DELETED check with a conditional that uses the 4K status when the
incoming request is 4K (e.g., (request.is4k ? r.media?.status4k :
r.media?.status) !== MediaStatus.DELETED), keeping the rest of the predicate
(r.requestedBy.id, r.isAutoRequest) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7de26685-2257-4c06-92bd-aaeff4cbdb86
📒 Files selected for processing (3)
server/entity/MediaRequest.tsserver/lib/watchlistsync.test.tsserver/lib/watchlistsync.ts
fe34dc1 to
4ca0462
Compare
Allow watchlist sync to re-request movies and shows whose media status is DELETED, and fix the duplicate auto-request guard blocking both sync and manual requests
4ca0462 to
3f02025
Compare
Description
When a movie or show was deleted from the media server, its status was set to
DELETEDbut the existing completed auto-request record remained in the database. This caused watchlist sync to skip re-requesting it entirely and theautoRequestedTmdbIdsset included the stale auto-request, short-circuiting the filter before it even reached the status check. Even if that was fixed, theunavailableItemsfilter for movies excluded anything with a status other thanUNKNOWN, soDELETEDmedia was never eligible. On top of that, manually requesting the deleted media also failed becauseMediaRequest.request()found the stale auto-request and threw aDuplicateMediaRequestError.This PR excludes
DELETEDmedia fromautoRequestedTmdbIds, addsDELETEDalongsideUNKNOWNin theunavailableItemsmovie filter, updates the duplicate auto-request guard to ignore stale requests where the media isDELETED, and ensures the media status is correctly reset toPENDINGwhen a new request is created for deleted media.How Has This Been Tested?
DELETED, then waiting for watchlist sync to run and confirming it re-requested it automaticallyScreenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
Bug Fixes
Tests