Skip to content

Fix Sonarr episode handling when media indexes are missing#2492

Closed
enoch85 wants to merge 3 commits into
mainfrom
fix/2491-sonarr-episode-handling
Closed

Fix Sonarr episode handling when media indexes are missing#2492
enoch85 wants to merge 3 commits into
mainfrom
fix/2491-sonarr-episode-handling

Conversation

@enoch85

@enoch85 enoch85 commented Mar 15, 2026

Copy link
Copy Markdown
Collaborator

Fix #2491

Summary

  • fix Sonarr episode handling for items that do not have a usable episode index by falling back to air date matching
  • make Sonarr and Radarr actions report success and failure explicitly instead of allowing false positives
  • only remove media from Maintainerr collections after the external action and any forced Seerr cleanup succeed
  • fix collection worker reporting so failed items are not reported as successfully handled
  • add regression coverage for episode matching, failure propagation, and collection handling order

This issue started as a Sonarr episode identification bug, but review of the full handling flow uncovered a second correctness problem in the same path: Maintainerr could mark media as handled and remove it from the collection before external actions had actually succeeded.

Fixing the issue safely required correcting both:

  • how Sonarr identifies certain episodes
  • how success and failure are propagated through the Servarr helpers, action handlers, collection handler, and worker flow

That is why the PR touches more than the original Sonarr lookup point.

Testing

  • yarn workspace @maintainerr/server test

Fall back to episode air dates when Sonarr episode actions cannot use an episode index, so daily episodes can still be matched and handled.

Propagate explicit success and failure from Sonarr and Radarr actions through the collection handler, and only remove media from Maintainerr collections after the external action and optional Seerr cleanup succeed.

Stop the collection worker from reporting failed media as handled, emit collection failure state when media handling fails, and add regression coverage for the Sonarr fallback and worker accounting.

Fixes #2491
@enoch85 enoch85 requested a review from ydkmlt84 as a code owner March 15, 2026 10:12
@enoch85 enoch85 self-assigned this Mar 15, 2026
Comment thread apps/server/src/modules/api/servarr-api/helpers/sonarr.helper.ts Fixed
enoch85 added a commit that referenced this pull request Mar 15, 2026
PR #2492 - Fix Sonarr episode handling when media indexes are missing
- Safely identify episodes via getEpisodeLookup (index or air date fallback)
- Return boolean from action handlers to detect servarr update failures
- Add airDate-based episode matching in Sonarr helper
@enoch85 enoch85 marked this pull request as draft March 26, 2026 19:14
@enoch85 enoch85 added this to the 3.5.0 milestone Apr 7, 2026
@enoch85 enoch85 modified the milestones: 3.5.0, 3.6.0 Apr 9, 2026 — with GitHub Codespaces

enoch85 commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #2653.\n\nThe valid Sonarr fixes from this branch were ported onto current \ in a smaller follow-up PR that preserves the newer metadata-based lookup and current collection-handling behavior.\n\nPlease continue review on #2653 instead of this stale branch.

@enoch85 enoch85 closed this Apr 10, 2026

enoch85 commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #2653.

The valid Sonarr fixes from this branch were ported onto current development in a smaller follow-up PR that preserves the newer metadata-based lookup and current collection-handling behavior.

Please continue review on #2653 instead of this stale branch.

@enoch85 enoch85 deleted the fix/2491-sonarr-episode-handling branch April 10, 2026 18:26
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.

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

2 participants