Skip to content

fix(scanners): don't orphan a show Sonarr carries under another tvdb id - #3605

Open
fallenbagel wants to merge 1 commit into
developfrom
fix/sonarr-orphan-tmdb-gate
Open

fallenbagel wants to merge 1 commit into
developfrom
fix/sonarr-orphan-tmdb-gate

Conversation

@fallenbagel

@fallenbagel fallenbagel commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Description

The Sonarr orphan cleanup decides a show is gone from Sonarr by looking for its stored TVDB id among the series it just scanned, then asking each server for that id. A show's stored TVDB id can come from TMDB when it was first requested, and that can differ from the TVDB id Sonarr has the series under. The scan still matches such a series to the show by its TMDB id and keeps it PROCESSING, but the cleanup then misses it under the stored id, resets the show to UNKNOWN and declines its request in the same run, even though Sonarr is still dowloading it.

The scan now also remembers the TMDB ids it resolved for each quality, and the cleanup skips a show whose TMDB id is among them before asking the servers.

How Has This Been Tested?

  • Sonarr orphan cleanup: a PROCESSING show stored under a different TVDB id than the one Sonarr carries, resolving to the same TMDB id, stays PROCESSING with its requested approved.

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Stack created with GitHub Stacks CLI • Give Feedback 💬

Summary by CodeRabbit

  • Bug Fixes
    • Sonarr scans now correctly recognize shows by their TMDB ID, even when the TVDB ID differs from the one returned by the scan.
    • Matching shows remain in processing instead of being incorrectly treated as missing, and their approved requests remain approved. This behavior applies to both standard and 4K profiles.

@fallenbagel
fallenbagel requested a review from a team as a code owner October 10, 2026 04:38
@fallenbagel
fallenbagel added this pull request to stack #3580 October 10, 2026 04:38
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9aca699c-c965-45f7-b26f-a58290a0da05
Commits

Reviewing files that changed from the base of the PR and between 15ecf91 and c76a504.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 921c5dad-ffaf-486f-b582-525c7472fb84
📥 Commits

Reviewing files that changed from the base of the PR and between ed5aba0 and 15ecf91.

📒 Files selected for processing (2)
  • server/lib/scanners/sonarr/index.ts
  • server/lib/scanners/sonarr/sonarr.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The Sonarr scanner now tracks scanned TMDB IDs separately for standard and 4K profiles. Orphan cleanup uses these IDs with TVDB IDs when deciding whether to reset processing media. A regression test covers a show returned with a different TVDB ID.

Changes: Sonarr orphan cleanup

Layer / File(s) Summary
Track scanned IDs for orphan cleanup
server/lib/scanners/sonarr/index.ts, server/lib/scanners/sonarr/sonarr.test.ts
The scanner clears and records scanned TMDB IDs by profile. Orphan cleanup checks both TMDB and TVDB IDs for standard and 4K scans. A regression test verifies that processing media and its approved request remain unchanged when the returned show has a different TVDB ID.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review 15ecf

The reported regression is covered by the new test, and no actionable issue remains from this review.

Pre-merge checks | Passed 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: preventing Sonarr from orphaning a show when the stored TVDB ID differs from Sonarr's TVDB ID.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the scan at dawn
Two sets of TMDB IDs are drawn
A show with a changed TVDB stays
Its request keeps its approved phase
The rabbit hops through fields of green

@fallenbagel
fallenbagel force-pushed the fix/sonarr-orphan-tmdb-gate branch from addc9ac to 15ecf91 Compare October 10, 2026 04:41
@fallenbagel fallenbagel added this to the v3.5.1 milestone Oct 10, 2026
@fallenbagel fallenbagel modified the milestones: v3.5.1, v3.5.2 Oct 21, 2026
@fallenbagel fallenbagel modified the milestones: v3.5.2, v3.5.3 Nov 1, 2026
Base automatically changed from fix/season-status-resets to develop November 1, 2026 20:39
The orphan cleanup matched shows to the scanned series by media.tvdbId, which can come from TMDB and differ from the tvdbId Sonarr uses for the series. processShow still found such a show by tmdbId and kept it PROCESSING, but the cleanup then missed it among the scanned ids, failed to confirm it against the servers under the wrong id, and reset it to UNKNOWN and declined its request in the same run. A show whose tmdbId was resolved from a scanned series of that quality is no longer treated as orphaned.
@fallenbagel
fallenbagel force-pushed the fix/sonarr-orphan-tmdb-gate branch from 15ecf91 to c76a504 Compare November 1, 2026 20:39
@cypress

cypress Bot commented Nov 1, 2026

Copy link
Copy Markdown

seerr    Run #3878

Run Properties:  status check passed Passed #3878  •  git commit c76a504321: fix(scanners): don't orphan a show Sonarr carries under another tvdb id
Project seerr
Branch Review fix/sonarr-orphan-tmdb-gate
Run status status check passed Passed #3878
Run duration 02m 04s
Commit git commit c76a504321: fix(scanners): don't orphan a show Sonarr carries under another tvdb id
Committer fallenbagel
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 33
View all changes introduced in this branch ↗︎

This branch has not been deployed

No deployments
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.

2 participants