Skip to content

fix(adminjob): match a complete refresh's unlinked series before resolving it - #4089

Merged
Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/complete-refresh-keeps-links-934
Nov 14, 2026
Merged

Quick104 merged 7 commits into
Silo-Server:mainfrom
rangoDJ:fix/complete-refresh-keeps-links-934

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #934
Related issue: #1209
Validation tasks: none (#1210 C2 passed with this bug recorded as a non-blocking gap; #1211 C2 doesn't run a Complete Refresh)

Other clients: Apple N/A (admin metadata job); Android N/A (same); Roku N/A (same)

Complete Refresh on a matched series, one of its seasons, or one episode failed with resolve rebuilt item: no rebuilt content found in refresh scope. The job had already cleared the content links of every file in scope by then. Until the background matcher linked them again, the item couldn't be refreshed (409 conflict, as in the issue's latest comment). Reset to Provider was half-applied in that window: its PATCH cleared the locks, and its refresh got the 409. Movies weren't affected.

This PR has no dependencies and can merge in any order.

Cause

prepareCompleteRefresh clears the scope's links, root claims and group claims. The executor then ingests the subtree and resolves the rebuilt item from the files linked again. The files are unchanged on disk, so:

  1. The scan reports nothing new or updated. Its scoped sync still queues the cleared series root in series_root_match_queue, but with available_at 10 s ahead (seriesRootQueueQuietWindow, the wait for files still being copied).
  2. shouldWaitForTVQueueSettle returns false (no new or updated files), so the ingest stops matching right after the scan. The scoped claim takes only rows whose available_at has passed, so it never takes the root.
  3. resolveCompleteRefreshTargets finds no linked file and fails. The background worker matches the root about 10 s later, which is why the show "came back" without intervention in the issue's comment.

The issue's description, that series roots rebuild asynchronously through the queue, is close. The specific gap is the quiet window that a scan with no new files doesn't wait for.

Approach

  • libraryingest.Executor.IngestUnlinkedSubtree is IngestSubtree for a subtree whose files lost their content links. For a TV or mixed library it waits out the queue's quiet window, as a scan with new files already does, so the roots the scan queued are matched before it returns. The flag travels in the context, which leaves ingest's signature as it was.
  • A Complete Refresh of a series, season or episode ingests its scope with it. Quick and Reset refreshes, and a Complete Refresh of a movie, keep IngestSubtree, since a movie queues no series root (8cd3695, from review).
  • Before it resolves the rebuilt item, a complete refresh waits for its scope's files to be linked again, checking every 500 ms for up to 60 s. The background match worker can claim the root once the quiet window passes, and the refresh then waits for that match too (8cd3695, from review). It still answers no rebuilt content found in refresh scope when nothing links them in that time.
  • A series root match links the root's files to a pending skeleton before it asks the providers. While the linked series is still pending, or was merged away since the refresh read the files, the refresh keeps waiting, so it never refreshes a skeleton the match replaces. If the match doesn't finish within the wait, it fails with rebuilt series is still being matched (11d531d and 3373c64, from review).
  • A season or episode lookup is retried only when the row isn't there yet; any other lookup error fails the refresh at once (4f4ae2c, from review).
  • A TV Complete Refresh now takes the same ~11 s settle wait a scan with new episodes takes; a movie's doesn't.

Validation

  • gofmt, go vet, and the changed-package lint are clean.

  • go test passes for internal/metadata, internal/libraryingest, internal/adminjob, internal/scanqueue and internal/api/handlers against a migrated Postgres 18.6 test database. One earlier full internal/metadata run failed and I didn't capture which test; the next two full runs passed.

  • New DB test TestCompleteRefreshRebuildsSeriesDB (internal/metadata, since it uses the package's stub-provider hook):

    • it runs the production scanner, series root queue, match worker, ItemRefreshResolver and ItemRefreshExecutor against a stub TV provider;
    • it scans a two-episode show, then runs Complete Refresh on the series, its season and an episode;
    • each must succeed, rebuild the requested item, and leave both files linked to the series and their episodes.

    It fails on main as the issue reports. The metadata refresh step after the resolve is a recorder there, because the plugin chain isn't wired in the test.

  • TestItemRefreshExecutorCompleteRefreshRebuildsAndMapsEpisodeTarget now also checks that complete mode ingests through IngestUnlinkedSubtree.

  • TestItemRefreshExecutorCompleteRefreshWaitsForTheRelink checks the wait for a late relink, giving up with errNoRebuiltContent, and that a movie target takes the plain ingest. With the wait removed it fails on the late relink, and with every complete refresh ingesting as unlinked it fails on the movie.

  • TestItemRefreshExecutorCompleteRefreshWaitsForTheSeriesMatch checks the wait for a pending series and the rebuilt series is still being matched failure. It fails with the status check disabled. The relink unit tests run on testing/synctest's fake clock.

  • TestCompleteRefreshRebuildsSeriesDB is listed in scripts/ci/db-contracts.txt, so the Go DB pins CI job runs it. On a scratch Postgres 18, it fails on main with the [bug] 'complete' item refresh on a series fails with 'no rebuilt content found in refresh scope' and leaves the show unmatched with orphaned episodes #934 error and passes on this branch, with the review fixes too.

  • Not run:

Evidence

No visible layout change: the job now completes instead of failing. The evidence is the new DB test on WSL2 (Ubuntu, go1.26.4 linux/amd64) with Postgres 18.6, main at a12425f82 and this PR at 2b7d4e6f4.

Before (main; diagnostic run of the same scenario):

after the library scan:
    Refresh Show (2020) - S01E01.mkv -> series-tvdb-724555986 / episode-tvdb-724555986-1-1
    Refresh Show (2020) - S01E02.mkv -> series-tvdb-724555986 / episode-tvdb-724555986-1-2
complete refresh of series-tvdb-724555986: resolve rebuilt item: no rebuilt content found in refresh scope
after it:
    Refresh Show (2020) - S01E01.mkv -> - / -
    Refresh Show (2020) - S01E02.mkv -> - / -
series root queue: .../tv/Refresh Show (2020) pending avail_in=00:00:09.951521
resolve season-tvdb-724555986-1: cannot determine scan scope because this item has no indexed files
resolve episode-tvdb-724555986-1-2: cannot determine scan scope because this item has no indexed files
$ go test -count=1 -run TestCompleteRefreshRebuildsSeriesDB ./internal/metadata/   # fix reverted, test kept
    complete_refresh_series_db_test.go:230: complete refresh of the series: resolve rebuilt item: no rebuilt content found in refresh scope
FAIL

After (this PR): the series, season and episode refreshes each complete, and both files stay linked after each.

$ go test -count=1 -v -run TestCompleteRefreshRebuildsSeriesDB ./internal/metadata/
--- PASS: TestCompleteRefreshRebuildsSeriesDB (46.56s)
ok  	github.com/Silo-Server/silo-server/internal/metadata	46.683s

Risks

  • A TV or mixed Complete Refresh takes about 11 s longer.
  • If the provider fails during the refresh, or another node's match worker dies holding the series root, the job waits up to 60 s for a relink, then fails, and the files in scope stay unlinked until the background matcher retries. The issue's "don't run the destructive step before the rebuild is known to succeed" isn't addressed here; this PR makes the rebuild succeed.
  • The new DB test takes about 46 s, most of it four settle waits.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code (Claude desktop app, Code tab)
  • Tool(s): Claude Code; GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Fix complete series refresh to match unlinked files before resolving targets

A complete refresh clears content links from files, so the old resolver could fail before the matcher rebuilt the series, season, or episode.

  • Complete refreshes of series, season, and episode targets now use IngestUnlinkedSubtree, which waits for the TV match queue to settle even when files are unchanged
  • resolveRelinkedTargets retries resolution for up to 60 seconds (500ms polling) while content is unlinked, targets are missing, or the series item is pending; it returns the latest result when the deadline passes and stops on context cancellation
  • resolveCompleteRefreshTargets distinguishes retryable conditions (unlinked scope files, missing season/episode rows, absent or pending series status) from terminal lookup failures via new sentinel errors
  • Server startup in main.go passes the item repository to the executor as its status reader
  • Adds a PostgreSQL integration test (TestCompleteRefreshRebuildsSeriesDB) covering series, season, and episode complete refreshes through the production workflow
  • Behavioral Change: complete refreshes of series-type targets can now take up to 60 seconds waiting for relinking; movie and other refresh modes are unchanged

Macroscope summarized 3373c64.

…lving it

Complete Refresh clears the scope's content links, then ingests the
subtree and resolves the rebuilt item from the files it links again.
For a series, a season or an episode the files are unchanged on disk,
so the scan reported nothing new or updated and the ingest did not wait
out the TV match queue's quiet window. The series roots the scan queued
only became claimable about 10 seconds later, after the ingest had
returned, and the refresh failed with "no rebuilt content found in
refresh scope" with every file in scope unlinked. The background
worker linked them again later; until then the item could not be
refreshed (409).

libraryingest gets IngestUnlinkedSubtree, which waits out the quiet
window for a TV or mixed library as a scan with new files does, and
Complete Refresh ingests its scope with it. A TV Complete Refresh now
takes the same ~11 s settle wait a scan with new episodes takes.

TestCompleteRefreshRebuildsSeriesDB runs the production scan, series
root queue, matcher and item refresh against Postgres for a series, a
season and an episode.

Closes Silo-Server#934

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 132738ea-7605-48a9-9d13-b27b24664e9d
Commits

Reviewing files that changed from the base of the PR and between 11d531d and 3373c64.

Files selected for processing: 2

  • internal/adminjob/item_refresh.go
  • internal/adminjob/item_refresh_test.go
Walkthrough

Complete refreshes for series, seasons, and episodes now use unlinked-subtree ingestion and retry target resolution while files relink or matching completes. The change also adds TV queue settle handling for marked ingests and tests for refresh behavior.

Changes: Complete refresh relinking

Layer / File(s) Summary
Unlinked subtree ingest
internal/adminjob/item_refresh.go, internal/libraryingest/executor.go
The ingester interface and library executor add an unlinked-subtree path. Marked ingests for TV and mixed libraries wait for the TV queue settle window.
Refresh relink handling
internal/adminjob/item_refresh.go, internal/adminjob/item_refresh_test.go, internal/metadata/complete_refresh_series_db_test.go, cmd/silo/main.go, scripts/ci/db-contracts.txt
Complete refreshes for series, seasons, and episodes use unlinked ingestion and poll for linked files, requested targets, and pending item matches. Tests cover relinking, timeout behavior, partially linked files, late episode records, and refreshed targets.

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ItemRefreshExecutor
  participant LibraryIngestExecutor
  participant TVQueue
  participant FileRepository
  participant EpisodeRepository
  participant ItemRepository
  ItemRefreshExecutor->>LibraryIngestExecutor: IngestUnlinkedSubtree for complete series, season, or episode refresh
  LibraryIngestExecutor->>TVQueue: Wait for settle window on TV or mixed library
  LibraryIngestExecutor-->>ItemRefreshExecutor: Return ingest result
  loop Until refresh resolves or wait expires
    ItemRefreshExecutor->>FileRepository: Read files in refresh scope
    FileRepository-->>ItemRefreshExecutor: Return linked and unlinked files
    ItemRefreshExecutor->>EpisodeRepository: Look up requested episode when applicable
    EpisodeRepository-->>ItemRefreshExecutor: Return episode or not-found result
    ItemRefreshExecutor->>ItemRepository: Read linked item status when configured
    ItemRepository-->>ItemRefreshExecutor: Return pending or matched status
  end
Loading

Suggested reviewers: rhainland, quick104

Merge Risk: Low · previous review 11d53

Complete refresh of a series now waits for files to relink before resolving its target. In a rare case where a series merge finishes at the wrong moment, the refresh may proceed with an item that no longer exists. Treating a missing status as unresolved and retrying should close this before merge, but the impact is limited and recoverable by re-running the refresh.

Security architecture risk: Minimal · up to 11d53

The change waits for rebuilding to settle without establishing broader refresh authority or a new failure-containment regression. Clearing links before rebuilding remains an existing limitation, not a newly introduced behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The affected state is the existing server-derived refresh scope within a media folder. Depending on stored file and canonical-root information, a season or episode request can rebuild a broader series subtree. This scope derivation is unchanged by the PR; polling does not accept a client-supplied filesystem path or broaden its folder/path query.

Trust Boundaries and Controls

  • observed — The inspected HTTP path remains permission-gated for metadata curation. Its gate composition requires authentication, viewer access and a configured permission gate, failing closed when a required dependency is absent. The handler validates mode, resolves scope server-side and records the authenticated user's ID when creating the job. The route and handler are unchanged in the named comparison.

Resilience and Maintainability Implications

  • inferred — The added polling does not itself retain an ingest scope claim or prevent relinking: ingestion releases its local claim on return, and polling begins afterward using read-only resolution operations. Existing overlapping subtree ingestion is serialized within one process, but this is not evidence of distributed serialization or atomicity across unlinking and metadata refresh.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(adminjob): match a complete refresh's unlinked series before resolving it" matches the main change. The PR makes complete refreshes of series, seasons, and episodes ingest unlinked subt…
Linked Issues check Passed [#934] Requirement: a Complete Refresh of a matched series should either rebuild the series and relink its episodes, or fail without destroying existing links. The PR takes the rebuild path for series…
Out of Scope Changes check Passed The described changes tie to #934. IngestUnlinkedSubtree and its context marker apply only to complete refreshes of series, season, and episode targets. Quick, Reset, and movie complete refreshes keep…
Description check Passed The description is related to the changeset. It explains the Complete Refresh failure for matched series, seasons, and episodes (#934). It describes the cause (cleared content links and the series roo…
Full details: Title check

Explanation

The title "fix(adminjob): match a complete refresh's unlinked series before resolving it" matches the main change. The PR makes complete refreshes of series, seasons, and episodes ingest unlinked subtrees, wait for the TV queue to settle, and poll for relinked targets before resolving the rebuilt item. The title is concise and specific, and it names the affected package.

Full details: Linked Issues check

Explanation

[#934] Requirement: a Complete Refresh of a matched series should either rebuild the series and relink its episodes, or fail without destroying existing links. The PR takes the rebuild path for series, season, and episode complete refreshes. internal/adminjob/item_refresh.go at head declares IngestUnlinkedSubtree on ItemRefreshIngester, documented as matching the subtree before it returns. The previous review verified the executor path: internal/libraryingest/executor.go marks the context, and TV and mixed ingests then wait out the queue quiet window even when the scan reports no new files. The increment since the previous review adds the relink wait (500 ms poll, 60 s bound, retries while present non-extra files stay unlinked or the requested season or episode row is absent). This wait body lies beyond the readable range at head. The diff reads for item_refresh.go and executor.go returned no content, so I could not read the wait body or the added tests directly. Its behavior rests on the raw summary, the PR description, and the test descriptions. I did not run TestCompleteRefreshRebuildsSeriesDB. Residual gap: the issue's 'at minimum' sentence asks that the destructive step not run before rebuild success. prepareCompleteRefresh still clears links first. If the provider fails, links stay cleared until the background matcher retries. The PR states this and does not address it.

Full details: Out of Scope Changes check

Explanation

The described changes tie to #934. IngestUnlinkedSubtree and its context marker apply only to complete refreshes of series, season, and episode targets. Quick, Reset, and movie complete refreshes keep IngestSubtree, per the PR description, the raw summary, and the visible resolver code, which routes complete mode through buildCompleteRequest only. The relink wait, the errNoRebuiltContent sentinel, the cmd/silo/main.go wiring of itemRepo, and the CI contract entry in scripts/ci/db-contracts.txt support the same rebuild path. The new tests verify it. No unrelated change appeared in the evidence I could read. The wait body and its tests were not read directly at head, so that part rests on the PR description and summaries.

Full details: Description check

Explanation

The description is related to the changeset. It explains the Complete Refresh failure for matched series, seasons, and episodes (#934). It describes the cause (cleared content links and the series root match queue delay), the approach (IngestUnlinkedSubtree, a 60-second relink wait, and a series pending-status check), validation (new DB test, unit tests, CI contract), and risks (about 11 seconds longer for TV refreshes, failure on provider errors). This matches the code summaries for item_refresh.go, executor.go, the tests, main.go, and db-contracts.txt.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 13, 2026
@silo-kody

silo-kody Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish labels Nov 13, 2026
Comment thread internal/libraryingest/executor.go Resolved
Comment thread internal/libraryingest/executor.go Resolved
…for series

Two gaps in the previous commit, from review:

- The background match worker can claim a series root once its quiet
  window passes, before the ingest's scoped matcher does. The ingest's
  settle wait then ends while that match is still running, and the
  refresh found no linked file. Before it resolves the rebuilt item, a
  complete refresh now waits for its scope's files to be linked again,
  checking every 500 ms for up to 60 s, whichever matcher links them.
  It still answers "no rebuilt content found in refresh scope" when
  nothing links them in that time.
- A complete refresh of a movie in a mixed library waited out the TV
  queue's quiet window, though a movie queues no series root. Only a
  series, season or episode target ingests as unlinked now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@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: 1

Review info

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: 2fbf29bb-e8a2-4871-9460-1dbce8c8a27e
Commits

Reviewing files that changed from the base of the PR and between 8d68c47 and 8cd3695.

Files selected for processing: 4

  • internal/adminjob/item_refresh.go
  • internal/adminjob/item_refresh_test.go
  • internal/libraryingest/executor.go
  • internal/metadata/complete_refresh_series_db_test.go

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

Comment thread internal/adminjob/item_refresh.go Resolved
From review: the relink wait ended as soon as one file in scope was
linked, so the refresh could finish while others still weren't, and a
season or episode whose row appeared only after the first file linked
failed at once with "rebuilt ... target not found".

The wait now continues while any present file in scope (extras aside)
is unlinked or the requested season or episode isn't there yet, within
the same 60 s bound. When the bound passes it resolves with what is
linked, so a file that never matches doesn't fail the refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@rangoDJ

rangoDJ commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

On CodeRabbit's merge-risk note for 8cd3695: both points held. Fixed in f0d5dc6.

  • The refresh finished on the first relinked file. The wait now continues while any present file in scope (local extras aside) is still unlinked, within the same 60 s bound.
  • A season or episode row that appears after the first file links failed at once. "Rebuilt season/episode target not found" is now retried within the wait too.

When the bound passes, the refresh resolves with what is linked, so a file that never matches doesn't fail it.

TestItemRefreshExecutorCompleteRefreshWaitsForTheWholeScope covers a scope with one file linked three reads late, an episode row that appears on the third lookup, and a file that never links. With the old wait, the first case fails.

Comment thread internal/adminjob/item_refresh.go Resolved
Comment thread internal/adminjob/item_refresh.go Resolved
Quick104 and others added 3 commits November 14, 2026 13:55
… run its DB test in CI

A failed season or episode lookup was retried for the whole relink wait
and then reported as a missing target. Only a not-found result is retried
now; any other error returns at once.

List TestCompleteRefreshRebuildsSeriesDB in scripts/ci/db-contracts.txt so
CI runs it, note why it takes about 45 s, and drop its executable bit. The
relink unit tests run on synctest's fake clock instead of the real 500 ms
poll.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…still being matched

A series root match links the root's files to a pending skeleton before it
asks the providers, and the provider match can then merge that skeleton
into another item. When another worker claimed the root, the relink poll
saw every file linked and resolved the refresh to the skeleton, so the job
refreshed and reported an item that the match was about to replace.

A complete refresh of a series, season or episode now keeps waiting while
the linked series is still pending, and fails with "rebuilt series is
still being matched" if the match doesn't finish within the wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Quick104 Quick104 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.

Review of e94a399b78 (this branch with main merged in; main's #4022 changed item_refresh.go). Three findings below. I'm fixing all three in commits on this branch, so there's no need to change anything yourself. The summary comment follows once the fixes are pushed.

🤖 Claude Code in T3 Code (claude-opus-5-5)

Comment thread internal/adminjob/item_refresh.go Resolved
Comment thread internal/adminjob/item_refresh_test.go Resolved
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Nov 14, 2026
@silo-kody

silo-kody Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Quick104 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 3373c6437b (this branch with main merged in, plus the review fixes below).

The fix is right. It reuses the settle wait a scan with new episodes already takes, and a relink wait covers the background worker claiming the root first. TestCompleteRefreshRebuildsSeriesDB fails on main with the #934 error (complete refresh of the series: resolve rebuilt item: no rebuilt content found in refresh scope) and passes on this branch. I ran both on a scratch Postgres 18.

Fixed on this branch

  • Merged main in (e94a399). Main's fix(adminjob): keep podcast IDs through a complete metadata refresh #4022 changed item_refresh.go; the merge was clean.
  • A complete refresh no longer resolves to a pending series skeleton that another worker is still matching (11d531d). It also no longer resolves to one the match merged away between its two reads (3373c64, Kody's thread).
  • A failed season or episode lookup fails the refresh at once instead of being retried as "not found" for 60 s (4f4ae2c, Kody's thread).
  • TestCompleteRefreshRebuildsSeriesDB is listed in scripts/ci/db-contracts.txt, so CI runs it. Its source says why it takes about 45 s, and its exec bit is gone (4f4ae2c).
  • The relink unit tests run on testing/synctest's fake clock, in 0 s instead of 1.6 s and 2.6 s (4f4ae2c).

Left for the maintainers

  • Complete Refresh still clears links before it knows the rebuild will succeed. If the provider fails, or another node's match worker dies holding the series root (its lease runs two hours), the refresh fails after 60 s and the series stays unlinked until the matcher retries. The PR body lists this as a risk. Fixing it means keeping links until the rebuild commits, which is the second half of [bug] 'complete' item refresh on a series fails with 'no rebuilt content found in refresh scope' and leaves the show unmatched with orphaned episodes #934. With this PR as it stands, Closes #934 closes that half too.
  • Possibly: split versions under a refreshed series. ClearContentLinksByPathPrefix clears files that Split Versions pinned with a file-scope identity override, and the root relink skips those files. If nothing else relinks them, the refresh succeeds after the 60 s wait with those files detached. I haven't confirmed whether the match relinks them; this comes from reading the source, not a run.

Other feedback

  • Kody's DB-error finding is fixed. Its repeated-read note stays as it is: a file in scope stays unlinked only when the root match fails, so the reads are bounded by the 60 s wait on a path that is already failing. CodeRabbit's whole-scope finding was handled in f0d5dc6.
  • A cross-provider review (Codex, gpt-6.1-sol, one round on e94a399b78) raised the skeleton race (fixed above) and the two open points above.

Validated features

No passed case changes. #1210 C2 passed with #934 recorded as a non-blocking gap, and #1211 C2 doesn't run a Complete Refresh. I couldn't run the validation board query, so I judged only #1209–#1211. The Validation tasks: line now reads none.

User manual and other clients

  • Manual: unaffected. The metadata guide already says Complete Refresh "clears the match and rebuilds the item from disk".
  • Other clients: N/A. This is a server-side admin job that every client starts the same way, and jellycompat doesn't reach complete refresh.

Fit: 9/10 · Readiness: 8/10 — conditional (assuming CI is green)

🤖 Claude Code in T3 Code (claude-opus-5-5)

Comment thread internal/adminjob/item_refresh.go Resolved
…merged away

The provider match can merge a series skeleton into another item between
the refresh's file read and its status read. The status read then has no
row for the skeleton, and the refresh went ahead with the deleted ID. A
missing status now counts as a match still in progress, so the next read
finds the files on the item that replaced it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@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: 1

Review info

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: ac2bd4d9-7821-437c-abb1-078a17c5463d
Commits

Reviewing files that changed from the base of the PR and between e94a399 and 11d531d.

Files selected for processing: 5

  • cmd/silo/main.go
  • internal/adminjob/item_refresh.go
  • internal/adminjob/item_refresh_test.go
  • internal/metadata/complete_refresh_series_db_test.go
  • scripts/ci/db-contracts.txt

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

Comment thread internal/adminjob/item_refresh.go Resolved
@Quick104
Quick104 merged commit db18946 into Silo-Server:main Nov 14, 2026
22 checks passed
@rangoDJ
rangoDJ deleted the fix/complete-refresh-keeps-links-934 branch November 15, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] 'complete' item refresh on a series fails with 'no rebuilt content found in refresh scope' and leaves the show unmatched with orphaned episodes

2 participants