Skip to content

fix(requests): reset orphaned season statuses when a request is deleted#3279

Open
Knat-Dev wants to merge 5 commits into
seerr-team:developfrom
Knat-Dev:fix/reset-season-statuses-on-request-delete
Open

fix(requests): reset orphaned season statuses when a request is deleted#3279
Knat-Dev wants to merge 5 commits into
seerr-team:developfrom
Knat-Dev:fix/reset-season-statuses-on-request-delete

Conversation

@Knat-Dev

@Knat-Dev Knat-Dev commented Jul 21, 2026

Copy link
Copy Markdown

Description

Once a user deletes a request the season rows of the request stay PENDING/PROCESSING forever, so the show's seasons can not be re-requested.

In this change we make sure to reset those season rows back to UNKNOWN.

Disclosure: I used AI tooling to help investigate the root cause and draft the patch, though I reviewed it myself and questioned it heavily. I hit the bug myself on my own instance and verified both the reproduction and the fix by hand.

How Has This Been Tested?

I ran the reproduction which has been stated under #3278 with 3.3.0 as well as this branch, on my own live instance with real Sonarr.

Stock 3.3.0: after deleting the request the season row stayed PROCESSING in the db and the UI disabled the season toggle.
On this branch: after deleting the request the season toggle was off and enabled.

Also ran typecheck, lint and the full test suite on this branch (133/133)

Screenshots / Logs (if applicable)

Stock 3.3.0:
image

^ Stuck in PROCESSING

This branch:
image

^ Back to UNKNOWN

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)

Summary by CodeRabbit

  • Bug Fixes
    • Improved TV media season status recalculation after removing or declining parent requests, ensuring season states are updated correctly based on remaining active requests.
    • When a season is no longer covered by any active TV request, reset its status back to an unknown state (without affecting seasons still covered by other requests), preserving 4K-specific status as appropriate.
  • Tests
    • Added deterministic TV request-deletion test coverage to verify correct season status transitions and re-request behavior.

Seasons left PENDING/PROCESSING after their request was deleted could never be re-requested ("No
seasons available to request"). Mirrors the existing decline-path season reset.

fix seerr-team#3278
@Knat-Dev
Knat-Dev requested a review from a team as a code owner July 21, 2026 20:07
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a4a1d0d-a59d-404f-abec-617edf986a24

📥 Commits

Reviewing files that changed from the base of the PR and between 67bc286 and d9c4c98.

📒 Files selected for processing (1)
  • server/routes/request.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/routes/request.test.ts

📝 Walkthrough

Walkthrough

handleRemoveParentUpdate now loads media and request season relations, then resets TV seasons left in PENDING or PROCESSING when no remaining active request covers them. Tests verify orphan cleanup, request coverage, unaffected seasons, and 4K status behavior.

Changes

TV season status recalculation

Layer / File(s) Summary
Recalculate inactive TV seasons
server/subscriber/MediaRequestSubscriber.ts
The removal handler loads request and media seasons, identifies active seasons by request type, and changes uncovered pending or processing seasons to UNKNOWN.
Validate request deletion cleanup
server/routes/request.test.ts
TV request deletion tests verify orphaned seasons reset, covered seasons remain processing, unrelated seasons remain unchanged, and 4K status handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • seerr-team/seerr#3276 — Describes stale TV season statuses after request deletion, addressed by this cleanup.

Possibly related PRs

Suggested labels: preview

Suggested reviewers: 0xsysr3ll, m0nsterrr

Poem

I’m a rabbit with seasons to clear,
No stuck status shall linger here.
Pending hops to Unknown’s door,
Fresh requests can bloom once more!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main behavior change: resetting season statuses when a request is deleted.
Linked Issues check ✅ Passed The change addresses #3278 by resetting affected TV season statuses to UNKNOWN after request deletion, restoring re-requestability.
Out of Scope Changes check ✅ Passed All code changes and tests are directly related to fixing stale TV season statuses after request deletion.

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

Comment @coderabbitai help to get the list of available commands.

@fallenbagel fallenbagel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also needs tests, since there aren't any in this PR. request.test.ts's delete-restoration suite is movie-only, which is how this bug shipped in the first place. At minimum:

  • request-covered season at PROCESSING, delete, reset to UNKNOWN, re-request succeeds
  • season NOT covered by the deleted request at PROCESSING, delete, untouched
  • second active request covering the season, delete the first, stays PROCESSING
  • delete a non-4K request, status4k untouched

Comment thread server/subscriber/MediaRequestSubscriber.ts Outdated
Comment thread server/subscriber/MediaRequestSubscriber.ts
@Knat-Dev

Copy link
Copy Markdown
Author

Sounds good, I'll add them later today once I'm free 👍🏻

@Knat-Dev

Copy link
Copy Markdown
Author

Thanks for the review btw! I'll fix everything after work

Knat-Dev added 3 commits July 23, 2026 18:24
…uest

The reset swept every PENDING/PROCESSING season with no remaining active request, including seasons
an arr scan had set that were unrelated to the deleted request. Scope it to the seasons the request
covered and batch the season saves into one manager.save call.
Covered season resets to UNKNOWN and is re-requestable, uncovered season untouched, season kept
while a second active request covers it, and status4k untouched on a non-4K delete. Three of the
four fail on develop without the fix.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/routes/request.test.ts`:
- Around line 665-689: Extend the request cleanup test around the existing
“resets a request-covered PROCESSING season” case to also exercise
MediaStatus.PENDING, preferably by parameterizing the status inputs. For each
status, verify deletion resets the season to UNKNOWN and the same season can be
successfully re-requested.
- Around line 727-745: Add a complementary test alongside the existing non-4K
deletion case that seeds distinct `status` and `status4k` values, deletes a 4K
request, and asserts `status4k` resets while `status` remains unchanged.
Exercise the 4K request setup so the dynamic status-key branch is covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b26baa2e-773e-4d51-9701-1bea440fc341

📥 Commits

Reviewing files that changed from the base of the PR and between 1e16bc8 and 67bc286.

📒 Files selected for processing (2)
  • server/routes/request.test.ts
  • server/subscriber/MediaRequestSubscriber.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/subscriber/MediaRequestSubscriber.ts

Comment thread server/routes/request.test.ts Outdated
Comment thread server/routes/request.test.ts
Parameterize the covered-season reset over PENDING and PROCESSING, and add the inverse 4K case:
deleting a 4K request resets status4k and leaves status untouched, proving the status key is
selected per request type.
@Knat-Dev

Copy link
Copy Markdown
Author

Done, all applied :)

@Knat-Dev
Knat-Dev requested a review from fallenbagel July 23, 2026 16:41
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.

Deleting a TV request can leave its seasons stuck in Processing and block re-requests

2 participants