Skip to content

fix(blocklist): stop tag job from rebuilding entries on every run - #3705

Open
fallenbagel wants to merge 2 commits into
developfrom
fix/blocklisted-tags-media-wipe
Open

fallenbagel wants to merge 2 commits into
developfrom
fix/blocklisted-tags-media-wipe

Conversation

@fallenbagel

@fallenbagel fallenbagel commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Description

The Process Blocklisted Tags job deleted and recreated every tag-blocklisted media row on each run, taking that title's requests, seasons, issues and watchlist entries with it and resetting when it was added, so titles kept jumping to the top of Recently Added. The first time a title matched, it also blocklisted media already in the library.

The job now compares each run against the existing entries instead of rebuilding them, so a title that still matches keeps its media row. Media that is in the library or requested is never tag-blocklisted. A title that no longer matches loses its blocklist entry, and its media row is only removed if nothing else depends on it. If a discover query fails, existing entries are left as they are for that run.

How Has This Been Tested?

Added tests that run the job against a seeded database with TMDB mocked, covering media in the library, placeholders that still match or no longer match, failed queries, removed or invalid keywords and cancelled runs. The tests for the reported behaviour fail against the old job.

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • 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
    • Blocklist entries now reflect the tags that currently match each title, and outdated matches are removed.
    • If a tag search fails, existing tag-based blocklist entries are preserved.
    • Titles already in the library or with active requests are skipped during processing.
    • When a match is removed, associated titles are cleaned up only when no other activity or associations remain; otherwise, their status reflects active requests or returns to an unknown state.

The job deleted every tag-sourced media row on each run and recreated it, losing requests and
resetting mediaAddedAt, and its first match overwrote media already in the library. It now diffs
each run against the existing entries, skips media in the library or requested, and only removes
stale entries when every discover query succeeded.

fixes #3668
@fallenbagel
fallenbagel requested a review from a team as a code owner November 9, 2026 13:42
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The processor now collects tag matches during discovery and reconciles tag-derived entries afterward. It skips reconciliation when discovery fails. It removes stale entries and deletes or restores associated media according to statuses and references.

Changes: Blocklisted tag processing

Layer / File(s) Summary
Discover and collect tag matches
server/job/blocklistedTagsProcessor.ts, server/job/blocklistedTagsProcessor.test.ts
The processor tracks keyword matches by title and skips titles with selected media statuses or active requests. Tests cover repeated runs, available media, and matching tags.
Reconcile matched tag entries
server/job/blocklistedTagsProcessor.ts, server/job/blocklistedTagsProcessor.test.ts
The processor skips reconciliation after discovery failures, updates tags for matched entries, and creates linked placeholder media when needed. Tests cover discovery failures, matching entries, and placeholder media creation.
Remove stale entries and restore media
server/job/blocklistedTagsProcessor.ts, server/job/blocklistedTagsProcessor.test.ts
The processor removes stale entries in batches, preserves media with requests or other references, and restores statuses based on active requests. Tests cover stale entries, pending and completed requests, empty or invalid tags, and cancellation.

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

Change: Bug fix

Possibly related PRs

  • seerr-team/seerr#3695: Sets Blocklist.blacklistedTags to NULL for copied SQLite rows that lack the column, supporting the processor’s tag-entry classification.

Suggested reviewers: gauthier-th, m0nsterrr

Merge Risk: Low · up to b285c

The reconciliation changes are mergeable with awareness of the accepted narrow race that can lose a concurrently added watchlist entry. Cancellation rollback, missing-media repair, and protection against overwriting library statuses are present.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: preventing the blocklist tag job from rebuilding entries on every run.
Linked Issues check Passed Directly linked issue [#3668] requires that the Process Blocklisted Tags job stop deleting and recreating tag-blocklisted media rows, keep the timestamps of available media, and avoid tag-blocklisting…
Out of Scope Changes check Passed The supplied whole-PR summary lists two changed files: server/job/blocklistedTagsProcessor.ts and server/job/blocklistedTagsProcessor.test.ts. The processor changes implement [#3668]: they remove the …
Full details: Linked Issues check

Explanation

Directly linked issue [#3668] requires that the Process Blocklisted Tags job stop deleting and recreating tag-blocklisted media rows, keep the timestamps of available media, and avoid tag-blocklisting available media. The reviewed head of server/job/blocklistedTagsProcessor.ts meets these requirements. (1) The delete-all cleanup is removed. Existing tag entries are reconciled in place: reconcileTagEntries updates blocklistedTags only when the value changes, and it keeps the media row of a title that still matches. (2) processResults skips titles whose media status is AVAILABLE, PARTIALLY_AVAILABLE, PROCESSING, or PENDING (4K or non-4K), and titles with PENDING, APPROVED, or FAILED requests, so these titles are not newly tag-blocklisted. (3) Stale entries are removed. An entry whose media is library or requested loses its blocklist row, and its media row is not deleted. removeStaleEntries deletes a media row only when both statuses are BLOCKLISTED and it has no request, issue, watchlist, or season. (4) When a discover query fails, reconcileTagEntries returns early, so existing entries are unchanged for that run. The test file server/job/blocklistedTagsProcessor.test.ts was assessed from the supplied summary only; its contents were not read, and the test results were not run.

Full details: Out of Scope Changes check

Explanation

The supplied whole-PR summary lists two changed files: server/job/blocklistedTagsProcessor.ts and server/job/blocklistedTagsProcessor.test.ts. The processor changes implement [#3668]: they remove the delete-all cleanup, reconcile tag entries, protect library and requested media, handle failed discovery, and restore media statuses for matched titles. The new tests cover these behaviors. The reviewed processor code shows no unrelated product, API, UI, schema, or settings change. The schedule file under server/job was listed but not reported as changed. Its status is not confirmed by a diff, since the diff tool was unavailable for this path.

  • 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 each tag at dawn,
And leaves available titles on.
Stale entries hop out of the queue,
While linked media stays in view.
Fresh matches find their tags in place,
Then quiet settles on the database.

@cypress

cypress Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

seerr    Run #3936

Run Properties:  status check passed Passed #3936  •  git commit b285ce7c8e: fix(blocklist): stop tag job from rebuilding entries on every run
Project seerr
Branch Review fix/blocklisted-tags-media-wipe
Run status status check passed Passed #3936
Run duration 02m 25s
Commit git commit b285ce7c8e: fix(blocklist): stop tag job from rebuilding entries on every run
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 ↗︎

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@fallenbagel
fallenbagel force-pushed the fix/blocklisted-tags-media-wipe branch from f44a4e3 to 4c6bf6f Compare November 9, 2026 15:04
coderabbitai[bot]

This comment was marked as resolved.

@seerr-automation-bot seerr-automation-bot added this to the v3.5.3 milestone Nov 9, 2026
@fallenbagel
fallenbagel force-pushed the fix/blocklisted-tags-media-wipe branch from 4c6bf6f to 1d1450c Compare November 9, 2026 15:33
coderabbitai[bot]

This comment was marked as low quality.

@fallenbagel
fallenbagel force-pushed the fix/blocklisted-tags-media-wipe branch from 1d1450c to b640d81 Compare November 9, 2026 15:49
@fallenbagel fallenbagel changed the title fix(blocklist): stop tag job from deleting and recreating media fix(blocklist): stop tag job from rebuilding entries on every run Nov 9, 2026
coderabbitai[bot]

This comment was marked as low quality.

@fallenbagel
fallenbagel force-pushed the fix/blocklisted-tags-media-wipe branch from b640d81 to b285ce7 Compare November 9, 2026 16:05
coderabbitai[bot]

This comment was marked as low quality.

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.

Process Blocklisted Tags recreates available media every run, so they reappear in "Recently Added"

2 participants