fix: prevent false watchlist evaluation when plex.tv is unreachable#2445
Merged
Conversation
When plex.tv times out, ExternalApiService.get() returns undefined. PlexTvApi.getUsers() passed this to xml2js parseStringPromise() causing a crash, and getUser() accessed .user on undefined. Both are now guarded. More critically, getCorrectedUsers() silently returned users without UUIDs, causing watchlist getters to evaluate as "not on anyone's watchlist" and incorrectly flag media for deletion. The watchlist getters now detect missing UUIDs and return null, which the rule comparator treats as "unable to determine" and skips the comparison.
enoch85
added a commit
that referenced
this pull request
Mar 1, 2026
PR #2445 - fix: prevent false watchlist evaluation when plex.tv is unreachable - Guard PlexTvApi.getUsers() and getUser() against undefined responses from timed-out plex.tv requests - Detect missing UUIDs in getCorrectedUsers() and return null from watchlist getters - Rule comparator treats null as "unable to determine" and skips the comparison, preventing false deletions
…check Fix the null-skip logic in the rule comparator — the old pattern (x !== undefined || null) never actually guarded against null. Use x != null so getters returning null correctly skip the comparison. Add the same undefined-response guard to getDevices() that getUsers() and getUser() already have.
Contributor
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #2446
Summary
PlexTvApi.getUsers()andgetUser()againstundefinedresponses fromExternalApiService.get()(returned on timeout/network errors), preventing crashes in xml2js parsing and property accesswatchlist_isWatchlisted,watchlist_isListedByUsers) by checking for missing user UUIDs, and returnnullto skip the rule comparison instead of falsely evaluating as "not on anyone's watchlist"Root Cause
When
plex.tvtimes out,ExternalApiService.get()catches the error and returnsundefined.PlexTvApi.getUsers()passed this directly toxml2js.parseStringPromise(), causingTypeError: Cannot read properties of undefined (reading 'toString'). The error was caught upstream, butgetCorrectedUsers()then silently returned users without UUIDs (since plex.tv enrichment failed). The watchlist getters filtered out all users (none had UUIDs), the loop never executed, andwatchlist_isWatchlistedreturnedfalse— incorrectly flagging media for deletion.Test plan
yarn build)yarn test— 494/494 passing)