You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(adminjob): match a complete refresh's unlinked series before resolving it - #4089
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:
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).
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.
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.
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)
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
…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.
ClosesSilo-Server#934
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
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.
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
[#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
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
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
…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]>
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
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]>
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.
… 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]>
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.
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.
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).
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)
Fit: fixes a broken admin repair in the core catalog flow, at the boundary that owns it, and reuses the existing settle wait. A TV Complete Refresh now takes about 11 s longer.
…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]>
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingimpact: usabilityCore flow broken or severely blockedpriority: P2Limited scope, workaround exists, or polishsize/XL500–999 added + deleted lines (all files); change volume, not priority.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
prepareCompleteRefreshclears 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:series_root_match_queue, but withavailable_at10 s ahead (seriesRootQueueQuietWindow, the wait for files still being copied).shouldWaitForTVQueueSettlereturns false (no new or updated files), so the ingest stops matching right after the scan. The scoped claim takes only rows whoseavailable_athas passed, so it never takes the root.resolveCompleteRefreshTargetsfinds 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.IngestUnlinkedSubtreeisIngestSubtreefor 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 leavesingest's signature as it was.IngestSubtree, since a movie queues no series root (8cd3695, from review).no rebuilt content found in refresh scopewhen nothing links them in that time.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 withrebuilt series is still being matched(11d531d and 3373c64, from review).Validation
gofmt,go vet, and the changed-package lint are clean.go testpasses forinternal/metadata,internal/libraryingest,internal/adminjob,internal/scanqueueandinternal/api/handlersagainst a migrated Postgres 18.6 test database. One earlier fullinternal/metadatarun 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):ItemRefreshResolverandItemRefreshExecutoragainst a stub TV provider;It fails on
mainas the issue reports. The metadata refresh step after the resolve is a recorder there, because the plugin chain isn't wired in the test.TestItemRefreshExecutorCompleteRefreshRebuildsAndMapsEpisodeTargetnow also checks that complete mode ingests throughIngestUnlinkedSubtree.TestItemRefreshExecutorCompleteRefreshWaitsForTheRelinkchecks the wait for a late relink, giving up witherrNoRebuiltContent, 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.TestItemRefreshExecutorCompleteRefreshWaitsForTheSeriesMatchchecks the wait for a pending series and therebuilt series is still being matchedfailure. It fails with the status check disabled. The relink unit tests run ontesting/synctest's fake clock.TestCompleteRefreshRebuildsSeriesDBis listed inscripts/ci/db-contracts.txt, so theGo DB pinsCI 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:
make test-go.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,mainata12425f82and this PR at2b7d4e6f4.Before (
main; diagnostic run of the same scenario):After (this PR): the series, season and episode refreshes each complete, and both files stay linked after each.
Risks
Checklist
AI Disclosure
🤖 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.
IngestUnlinkedSubtree, which waits for the TV match queue to settle even when files are unchangedresolveRelinkedTargetsretries 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 cancellationresolveCompleteRefreshTargetsdistinguishes retryable conditions (unlinked scope files, missing season/episode rows, absent or pending series status) from terminal lookup failures via new sentinel errorsTestCompleteRefreshRebuildsSeriesDB) covering series, season, and episode complete refreshes through the production workflowMacroscope summarized 3373c64.