Skip to content

Fix plex.tv DNS blips blocking array restore, clarify locked admin toggles - #198

Merged
StudioNirin merged 2 commits into
StudioNirin:mainfrom
Brandon-Haney:fix/issue-197-plextv-dns-resilience
Jul 26, 2026
Merged

Fix plex.tv DNS blips blocking array restore, clarify locked admin toggles#198
StudioNirin merged 2 commits into
StudioNirin:mainfrom
Brandon-Haney:fix/issue-197-plextv-dns-resilience

Conversation

@Brandon-Haney

Copy link
Copy Markdown
Collaborator

Fixes #197

What's happening

A user reported this during a scheduled run:

ERROR - [PLEX API] Error (load user tokens): ... Failed to resolve 'plex.tv' ([Errno -5] No address associated with hostname)
WARNING - [PLEX API] plex.tv unreachable - using cached user data only
WARNING - [PLEX API] Watchlist data will be incomplete - array restore will be skipped

Two problems fell out of it, plus a UI gap.

1. The first plex.tv call of a run had no retry

_get_main_account() called myPlexAccount() bare. It was the only plex.tv call in core/plex_api.py not going through _retry_plextv_call, which already retries requests.ConnectionError three times with 2s/4s backoff. A NameResolutionError surfaces as exactly that exception, so a brief DNS hiccup took out the whole run when a retry would have gone straight through.

Now wrapped in the existing helper. Non-transient errors (auth, parse) still fail fast on the first attempt.

2. A plex.tv outage blocked array restore even with watchlist disabled

The failure path set _watchlist_data_complete = False unconditionally, and _process_media() uses that flag to skip moving watched files back to the array. With watchlist caching turned off, no cached file is held by the watchlist, so there was nothing incomplete to guard against. Users who don't use the feature at all were still losing their array restore whenever plex.tv had a moment.

PlexManager now takes watchlist_enabled and only flags watchlist data when watchlist caching is actually on. _process_media() checks watchlist_toggle alongside the flag as a second gate. The OnDeck guard is unchanged, and behaviour with watchlist enabled is identical to before.

3. The locked admin toggles didn't explain themselves

The admin row's OnDeck and Watchlist toggles are disabled by design, but nothing said why or where to go instead, so the reporter thought they'd hit a bug. Added a tooltip on each, and a hint under the table linking to the global switch at Settings > Cache > Enable Watchlist Caching, which is what actually turns watchlist caching off for everyone.

Testing

New tests/test_plextv_main_account_resilience.py, 7 tests:

  • transient DNS failure then success returns the account and leaves both health flags clean
  • sustained failure stops at PLEXTV_MAX_RETRIES and reports plex.tv unreachable
  • happy path makes exactly one call
  • auth-shaped errors aren't retried
  • watchlist enabled still flags data incomplete
  • watchlist disabled leaves data complete so restore proceeds
  • constructor defaults watchlist_enabled=True for existing callers

Full suite: 1207 passed.

Manual verification

  1. Settings > Users, confirm the admin row's toggles show a tooltip on hover and the hint below links to the cache tab.
  2. Click the hint link, confirm it lands on Enable Watchlist Caching and flashes it.
  3. Turn off Enable Watchlist Caching, block DNS for plex.tv, run a cache operation. The log should show "plex.tv unreachable" but no "array restore will be skipped", and watched files should still move back to the array.
  4. Turn Enable Watchlist Caching back on and repeat. The skip warning should return, matching current behaviour.

The first plex.tv call of a run, `myPlexAccount()` in `_get_main_account()`,
was the only plex.tv call not wrapped in `_retry_plextv_call`. A transient
DNS failure or connection reset there marked plex.tv unreachable for the
whole run, where the existing helper's 3 attempts with 2s/4s backoff would
have recovered.

A plex.tv failure also set `_watchlist_data_complete = False` unconditionally,
which gates array restore in `_process_media()`. With watchlist caching
disabled, no cached file is held by the watchlist, so a plex.tv outage was
blocking the restore of watched files for a feature the user wasn't running.
`PlexManager` now takes `watchlist_enabled` and only flags watchlist data
when watchlist caching is on; `_process_media()` checks `watchlist_toggle`
alongside the completeness flag.

Refs StudioNirin#197
The admin row's OnDeck and Watchlist toggles are disabled by design, but
nothing said so or pointed at the global switch. Adds a tooltip to each and
a hint linking to Settings > Cache > Enable Watchlist Caching, which is the
control that turns watchlist caching off for every user including admin.

Refs StudioNirin#197
@StudioNirin
StudioNirin merged commit af0f0cb into StudioNirin:main Jul 26, 2026
2 checks passed
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.

Failed to resolve 'plex.tv'

2 participants