Skip to content

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

@enoch85

Description

@enoch85

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.tsgetEpisodes() (line ~56) and UnmonitorDeleteEpisodes() (line ~156)
  • sonarr-action-handler.tsmediaData?.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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions