Skip to content

fix(scanners): reconcile orphaned Sonarr season requests - #214

Merged
snapetech merged 5 commits into
mainfrom
codex/sonarr-orphaned-season-recovery-20261012
Oct 13, 2026
Merged

snapetech merged 5 commits into
mainfrom
codex/sonarr-orphaned-season-recovery-20261012

Conversation

@snapetech

@snapetech snapetech commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When Sonarr loses a series, SeerrNG now resolves stale work per season for partially available or deleted shows. It settles affected requests when seasons are unmonitored and unavailable, including season rows already marked UNKNOWN by an earlier scan. Completed seasons stay intact, and requests with no active selections can be submitted again. Cleanup leaves state unchanged when metadata lookup or a series scan fails.

This builds on SeerrNG #209 and #213. It adapts the failure cases documented in Seerr PR #3606, which builds on Seerr PR #3579 and the identity guard in Seerr PR #3605. The legacy UNKNOWN rows described in Seerr issue #3576 are also covered through the verified scan path tracked in #3577. Per SeerrNG's contribution guide, this PR targets main; its history includes the #209 and #213 prerequisite commits.

OpenAI Codex assisted with the upstream audit, implementation, conflict resolution, and regression tests. Upstream references are disclosed here, and SeerrNG attribution is preserved.

How Has This Been Tested?

  • pnpm test:node server/lib/scanners/mediaCleanupBatches.test.ts server/lib/scanners/radarr/radarr.test.ts server/lib/scanners/sonarr/sonarr.test.ts server/test/MediaRequestSubscriber.test.ts — 90 passed, 0 failed, 0 skipped.
  • pnpm test:vitest src/components/RequestModal/TvRequestModal.tree.test.tsx src/components/RequestModal/TvCollectionRequestModal.contract.test.ts src/components/RequestModal/requestTreeData.test.ts src/components/RequestModal/requestAvailability.test.ts — 30 passed.
  • pnpm typecheck:server, pnpm typecheck:client, ESLint, Prettier, and git diff --check — passed.
  • pnpm release-notes:preview --base origin/main --head HEAD — passed.
  • Main was merged at e284420ee3683dd4ba3bfa2facc241c84cdba41e. The conflict resolution keeps its metadata-provider routing, available-request completion, failed-request repair flow, and active-season quota accounting alongside the per-season orphan cleanup and scan-failure guard.
  • GitHub-hosted Mode 2 validation is rerunning for the merge commit. Full candidate validation remains pending until those checks finish.
  • The branch includes Request UI changes from fix(requests): recover unmonitored movie and season requests #213. Visual inspection is unavailable because isolated browser tools are not exposed in this session; no host desktop or Chrome was used, and no rendered-interface pass is claimed.

Screenshots / Logs

No rendered screenshots are available. Focused local check results are summarized above; GitHub Actions will retain the hosted logs for the full validation run.

Release Notes

  • I added a release-note fragment under release-notes/.
  • This change is internal-only and does not need a user-facing release note.
  • The fragment includes audience, area, action, and breaking-change status.
  • I previewed the release text with pnpm release-notes:preview.

Checklist:

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:01:26.625987Z 1fafe0b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c842ef3bac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +241 to +245
if (
this.failedShowKeys.has(this.movieStatusKey(candidate.tmdbId, is4k)) ||
[...candidate.tvdbIds].some((tvdbId) =>
this.failedShowTvdbKeys.has(this.movieStatusKey(tvdbId, is4k))
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip deferred resets after unresolved cross-ID failures

When two same-quality Sonarr instances carry the same show under different TVDB IDs, one instance can enqueue a reset while the other fails its metadata lookup before resolvedTmdbId is assigned. markShowScanFailed then records only the second TVDB ID, while this guard checks the first ID stored on the candidate, so the reset proceeds and can decline a request even though the failed instance still monitors that season. Treat an unresolved profile scan failure as blocking deferred resets, as orphan cleanup already does.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91ce0d4ca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +438 to +440
if (deferStatusReset) {
const key = this.movieStatusKey(tmdbId, is4k);
if (processing) this.processingMovieKeys.add(key);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track processing movies before branching on persistence

  1. Confidence: high. When the same movie is first discovered on two same-quality Radarr servers, with the first instance monitoring it without a file and a later instance listing it as unmonitored, the first pass creates the PROCESSING media row but never adds processingMovieKeys because this bookkeeping is inside the existing branch. The later pass queues a deferred reset, which consequently changes the newly discovered movie to UNKNOWN despite the first instance still monitoring it. Record processing activity for new rows as well as existing rows so the final reconciliation preserves active scans.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

Comment on lines +1510 to +1518
if (deferStatusReset) {
if (season.is4kOverride && season.processing) {
this.processingSeasonKeys.add(
this.seasonStatusKey(tmdbId, true, season.seasonNumber)
);
} else if (!season.is4kOverride && season.processing) {
this.processingSeasonKeys.add(
this.seasonStatusKey(tmdbId, false, season.seasonNumber)
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track processing seasons created during this scan

  1. Confidence: high. When a series is first discovered on one same-quality Sonarr instance with a monitored, fileless season and is subsequently scanned from another instance where that season is unmonitored, the first pass creates the season as PROCESSING but does not register its processing key because this block only runs for existingSeason. The second pass then queues the season as stale, and deferred reconciliation resets both the season and potentially the series to UNKNOWN even though the first Sonarr instance still monitors it. Register processing keys before the existing/new-season split.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

# Conflicts:
#	server/lib/scanners/sonarr/index.ts
#	server/subscriber/MediaRequestSubscriber.ts
#	src/components/RequestModal/TvRequestModal.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fafe0b17a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +294 to +298
const remainingKnownSeason = media.seasons.some(
(season) =>
season[statusField] === MediaStatus.PROCESSING ||
season[statusField] === MediaStatus.PARTIALLY_AVAILABLE ||
season[statusField] === MediaStatus.AVAILABLE

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude specials from the aggregate reset check

When special episodes are enabled and season 0 remains PROCESSING, resetting an unmonitored regular season to UNKNOWN leaves the series aggregate permanently PROCESSING because this predicate counts season 0 as remaining activity. The normal processShow rollup deliberately considers only non-special seasons, so deferred reconciliation should apply the same exclusion; otherwise the request is declined while the series still appears in progress on every subsequent scan. Confidence: high.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

@snapetech
snapetech merged commit 868e156 into main Oct 13, 2026
31 checks passed
@snapetech
snapetech deleted the codex/sonarr-orphaned-season-recovery-20261012 branch October 13, 2026 15:00
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.

1 participant