Skip to content

feat(requests): record why a request failed - #3493

Open
fallenbagel wants to merge 1 commit into
fix/tvdb-request-flowfrom
feat/request-failure-reason
Open

fallenbagel wants to merge 1 commit into
fix/tvdb-request-flowfrom
feat/request-failure-reason

Conversation

@fallenbagel

@fallenbagel fallenbagel commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

A failed request gives no indication of why it failed. Whether Sonarr was unreachable, the series could not be identified, or its seasons are numbered differently than Sonarr expects, the request looks identical and offers the same unhelpful retry.

Now it records the reason a request failed and clears it when the request is retried. Nothing is displayed differently yet, that follows separately, but the cause is stored per request rather than living only in the server log.

How Has This Been Tested?

  • Tested by having a request fail and observing the db column

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)

Summary by CodeRabbit

  • New Features

    • Media requests now record specific failure reasons, including unavailable services, dispatch failures, unresolved TVDB IDs, and season-numbering issues.
    • Failure details are stored for future reference.
  • Bug Fixes

    • Retrying a failed media request now clears its previous failure reason.
    • Improved handling prevents conflicting TVDB assignments and excludes empty TV seasons from all-season requests.
  • Tests

    • Added coverage verifying reported failure reasons for common request failures.

@fallenbagel
fallenbagel added this pull request to stack #3491 September 9, 2026 22:14
@fallenbagel
fallenbagel requested a review from a team as a code owner September 9, 2026 22:14
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

The saved review history does not include the base for the last reviewed commit. This saved history cannot establish the base for an incremental review. Comment @coderabbitai full review to establish a new review baseline. No full review was started, and the last reviewed checkpoint was preserved.

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: 777d214a-56ff-42b9-a7ab-a4deb6769906

📥 Commits

Reviewing files that changed from the base of the PR and between a48b7bf and 04553d6.

📒 Files selected for processing (1)
  • server/entity/MediaRequest.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change adds classified failure reasons to media requests, persists them in PostgreSQL and SQLite, records them for Radarr and Sonarr failures, handles TVDB conflicts, and clears the reason on retry.

Changes

Media request changes

Layer / File(s) Summary
Failure reason contract and persistence
server/constants/media.ts, server/entity/MediaRequest.ts, server/migration/...
Adds five failure-reason values, a nullable entity field, and PostgreSQL and SQLite migrations.
Conflict-tolerant media persistence
server/entity/MediaRequest.ts
Checks TVDB ownership before clearing a conflicting identifier and rethrows unrelated save failures.
Failure recording and retry reset
server/subscriber/MediaRequestSubscriber.ts, server/subscriber/MediaRequestSubscriber.test.ts, server/routes/request.ts
Records failure reasons, verifies selected values, and clears the reason before retry.

Priority: ⬇️ Low

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant MediaRequestSubscriber
  participant MediaRequest
  participant MediaRequestDatabase
  participant RequestRoute
  MediaRequestSubscriber->>MediaRequest: Set failureReason and failed status
  MediaRequest->>MediaRequestDatabase: Save failure reason
  RequestRoute->>MediaRequest: Clear failureReason on retry
  MediaRequest->>MediaRequestDatabase: Save re-approved request
Loading

Suggested reviewers: xyerophyte

Merge Risk: 🟡 Moderate · up to 04553

A failed media save can discard a valid TVDB association when another row has the same identifier, risking incorrect media linkage; this should be fixed before merge.

🚥 Pre-merge checks | ✅ 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 and concisely describes the main change: recording failure reasons for requests.

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

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

@fallenbagel
fallenbagel force-pushed the feat/request-failure-reason branch from f89740d to 1410ba2 Compare September 10, 2026 04:47
@fallenbagel
fallenbagel force-pushed the feat/request-failure-reason branch from 1410ba2 to a48b7bf Compare September 14, 2026 22:50
coderabbitai[bot]

This comment was marked as low quality.

@fallenbagel
fallenbagel force-pushed the feat/request-failure-reason branch from a48b7bf to 04553d6 Compare September 14, 2026 23:58
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Sep 21, 2026
@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.

Every failure in the *arr dispatch path set the same FAILED status and sent the same notificaiton,
so a request rejected for mismatched season numbering was indistinguishable from one whose Sonarr
was simply unreachable. Store a reason alongside the status at each failure site, and clear it when
a failed request is retried.
@fallenbagel
fallenbagel force-pushed the feat/request-failure-reason branch from 04553d6 to e322e13 Compare September 22, 2026 03:39
@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Sep 22, 2026

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.

1 participant