Maintainerr icon indicating copy to clipboard operation
Maintainerr copied to clipboard

Episodes with undefined index (e.g. daily shows) are silently not deleted/unmonitored in Sonarr

Open enoch85 opened this issue 8 months ago • 1 comments

Bug

When a rule matches episodes whose Plex metadata has no index (episode number) — common with daily shows like Jeopardy! — the episodes are removed from the Maintainerr collection but never actually deleted or unmonitored in Sonarr.

Steps to Reproduce

  1. Create a rule targeting episodes of a daily show (e.g. Jeopardy!) using Sonarr.filePath and Tautulli.sw_amountOfViews
  2. Wait for the collection to be processed
  3. Observe that episodes are removed from the Maintainerr collection but remain in Sonarr (still monitored, files not deleted)

Expected Behavior

Matched episodes should be deleted/unmonitored in Sonarr regardless of whether Plex provides a numeric episode index.

Actual Behavior

  • Maintainerr logs show: Removed season 2026 episode undefined from show 'Jeopardy!'
  • The episode is removed from the Maintainerr collection but no Sonarr action is taken
  • Compare with SNL which works: Removed season 51 episode 13 from show 'Saturday Night Live'

Root Cause

  1. SonarrActionHandler.handleAction() fetches Plex metadata via mediaServer.getMetadata(), which returns undefined for the index field on certain daily show episodes
  2. This undefined is passed to SonarrApi.UnmonitorDeleteEpisodes() as [undefined]
  3. getEpisodes() in sonarr.helper.ts filters with episodeNumbers.includes(el.episodeNumber) — no episode matches undefined, so an empty array is returned
  4. The for loop does nothing, and the error is silently swallowed
  5. Meanwhile, the media has already been removed from the Maintainerr collection (there is a TODO in collection-handler.ts acknowledging this ordering issue)

Relevant Code

  • sonarr.helper.ts — getEpisodes() (line ~56) and UnmonitorDeleteEpisodes() (line ~156)
  • sonarr-action-handler.ts — mediaData?.index passed at line ~105
  • collection-handler.ts — collection removal before action (line ~49, has existing TODO)

Possible Fix

When the episode index is undefined, fall back to an alternative identification method — e.g. matching by Sonarr episode file path, air date, or episode file ID rather than episode number.

enoch85 avatar Mar 14 '26 17:03 enoch85

:tada: This issue has been resolved in version 3.6.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

maintainerr-automation avatar Apr 13 '26 02:04 maintainerr-automation