Skip to content

fix(adminjob): keep podcast IDs through a complete metadata refresh - #4022

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/3405-podcast-complete-refresh-ids
Nov 13, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/3405-podcast-complete-refresh-ids

Conversation

@Rhainland

@Rhainland Rhainland commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #3405
Related issue: N/A
Validation tasks: none

A complete metadata refresh of a podcast show or one of its episodes gave the show and every episode new content IDs. Favorites, watch progress and history are keyed by those IDs, so they disappeared from the profile after the refresh. This change keeps the existing IDs.

Before rescanning, a complete refresh clears the file links in its scope so the files are matched again. The podcast scanner finds an existing show through those links. Without them it created a new show and new episodes, and the old show was removed.

Approach

A complete refresh in a podcast library now keeps the file links. Root and group claims are still cleared, and the scan still re-reads every episode's tags, so a retagged title is picked up. In a podcast library, complete and quick refresh therefore index the show the same way. The podcast scanner already rewrites the show and its episodes on every scan, so podcasts lose no refresh behaviour that matters. Movie, series and mixed libraries are unchanged. docs/admin-catalog-api.md now says what complete does and why podcasts keep their links.

No client change is needed: the API shape is the same, and refreshed items keep their IDs. Jellycompat has no refresh path of its own.

Validation

  • New database test drives the real resolver, refresh executor, library ingest and podcast scanner for a show target and an episode target. It fails on main with new IDs and passes with the fix. It is listed in scripts/ci/db-contracts.txt.
  • Local server built from main and then from this branch, same database and synthetic podcast, movie and TV libraries, refresh run through POST /api/v2/admin/items/{id}/refresh-metadata with an admin token: see Evidence.
  • Movie, series and episode complete refresh on fresh libraries gave the same result on both builds.
  • go build ./..., gofmt -l ., go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery, make test-go, make verify-local-paths, make verify-case-collisions, make verify-size-ratchet, make verify-bidi: pass. On this host, four packages (internal/api/handlers, internal/backup, internal/ebookconvert, internal/uploads) fail make test-go only because the default temp directory is group-writable; they pass with a private TMPDIR.
  • Web checks and the API contract checks were not run: no web, route or OpenAPI files changed.

Evidence

Synthetic podcast show with two episodes. The show is a favorite and episode 1 is marked played, then the show gets a complete refresh.

main
  before: show 151689501767420177, episodes 151689501784197393, 151689501800974609
          GET /api/v2/favorites -> [151689501767420177]   GET /api/v2/progress -> [151689501784197393 completed]
  after:  show 151689594411206929, episodes 151689594427984145, 151689594428049681
          GET /api/v2/favorites -> []                     GET /api/v2/progress -> []

this branch (same database)
  before: show 151689921566918929, episodes 151689921583696145, 151689921583761681
          GET /api/v2/favorites -> [151689921566918929]   GET /api/v2/progress -> [151689921583696145 completed]
  after:  same IDs, same favorite, same progress

A complete refresh of an episode behaved the same way on each build. On this branch, an episode retagged before the refresh came back with its new title and the same ID, and a later full library scan kept all IDs.

Without a podcast metadata provider installed, the refresh job ends with refresh metadata: no metadata found from any provider on both builds, after the scan. A quick refresh fails the same way, so this is unrelated to the change.

Risks

None identified. The change applies only to podcast libraries, which are beta.

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 says there is none.

AI Disclosure

  • Harness: Claude Code (via T3 Code); Codex CLI for code review
  • Tool(s): Claude Code, Codex CLI
  • Model(s): claude-opus-5-5; gpt-6.1-sol (code review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: dual-code-review of the full branch diff, Claude Opus 5.5 and GPT 6.1 Sol reviewing independently on correctness, standards and spec. Neither found a correctness problem. GPT noted that CONTRIBUTING asks for tests in an existing file, so the new test moved into item_refresh_test.go. Opus noted that the podcast behaviour of complete refresh was undocumented, so docs/admin-catalog-api.md now covers it. Opus also suggested asserting the IDs again after a full rescan; dropped, because the podcast scanner tests already cover a rescan keeping a show's ID and the local run checked it. A re-review of those follow-up changes found nothing.

Note

Fix prepareCompleteRefresh to preserve podcast IDs on complete refresh

  • complete refresh used to clear file-to-content links under the scan-path prefix for all folder types. For podcast libraries this dropped show and episode IDs referenced by favorites and progress. item_refresh.go now takes the media folder into account and keeps links for podcast folders; other folder types still clear them.
  • Adds a database-backed regression test, TestCompleteItemRefreshKeepsPodcastIDsDB, that runs complete refreshes on a podcast show and episode and asserts IDs stay unchanged. It is registered in db-contracts.txt and skips when SILO_TEST_DATABASE_URL is unset.
  • Documents the new behavior in admin-catalog-api.md.
  • Behavioral Change: podcast folders no longer have content links cleared during complete-refresh preparation; non-podcast folders are unchanged.

Macroscope summarized 14e5c5d.

A complete refresh cleared the file links under the show folder before
rescanning it. The podcast scanner finds a show through those links, so
it created a new show and new episodes, which detached favorites,
progress and history. Podcast libraries now keep their links; the scan
still re-reads every episode's tags.

Closes Silo-Server#3405
@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

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 17 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: 8f98b69e-d687-49ca-80d6-694c8fc23a38
Commits

Reviewing files that changed from the base of the PR and between 0b579aa and 14e5c5d.

Files selected for processing: 4

  • docs/admin-catalog-api.md
  • internal/adminjob/item_refresh.go
  • internal/adminjob/item_refresh_test.go
  • scripts/ci/db-contracts.txt
  • 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 12, 2026
@silo-kody

silo-kody Bot commented Nov 12, 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 go Pull requests that update go code impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish labels Nov 12, 2026
@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 14e5c5dc1979467056c54a92b8401611a3702a3a

This fixes a real defect. On main, a complete refresh clears the file links in its scope. The podcast scanner finds an existing show only through those links, so it creates a new show and new episodes, and the scan's membership sweep deletes the old show. Favorites and progress on the old IDs are lost. Movie and series IDs come from their provider IDs, so they come back the same unless the match changes. Podcast IDs are newly generated, so every complete refresh replaced the show even when nothing on disk had changed.

Findings: none. The guard uses the same librarykind.IsPodcast(folder.Type) check that sends a scan to the podcast scanner. folder has already been loaded and checked by the time it is read. The scan still re-reads tags and relinks moved files under the show's advisory lock, so keeping the links loses no podcast behavior. Deleting the root and group claims has no effect on podcasts, because only the metadata matcher reads them.

Tests: TestCompleteItemRefreshKeepsPodcastIDsDB fails on the base for the reported reason (the show and both episode IDs change, and the scanner logs one item deleted) and passes on this head, both against a scratch Postgres. Its cleanup leaves no rows behind. CI is green.

Outside this PR (pre-existing on main, for maintainers to decide separately):

  • A podcast episode refresh still ends the job with ErrMetadataNotFound. The episode refresh step accepts only a parent of type series (refreshSeriesChildTarget in internal/metadata/service.go). The scan has already committed by then, so IDs survive, but the job reports failure. The PR body notes the same failure for a show refresh when no podcast provider is installed.
  • Complete refresh of an audiobook or ebook looks likely to lose its ID the same way: every lookup those scanners use goes through media_files.content_id, which the refresh clears. That is traced from source only, not run. Books are beta, and the refresh dialog warns about new IDs, so whether to change it is a product decision.

Validated features: not checked. The validation board could not be read from this session. From the code, only podcast complete refresh changes. Quick, reset, movie, series and episode refreshes and non-podcast scans share no changed code. Validation tasks: none is likely right but unverified.

User manual: no change needed. The metadata page says Complete Refresh "can give it a new ID or type", which stays true.

Other clients: N/A. The API is unchanged and items now keep their IDs. Jellycompat has no item-refresh path.

Second opinion: one cross-provider round (Codex, gpt-6.1-sol) on this head found no defect this PR introduced. It raised the two pre-existing points above.

Fit: 9/10 · Readiness: 9/10 — ready

Fit: a small fix at the point where a complete refresh destroys the identity the podcast scanner depends on. It changes no API, adds no setting, and leaves other library kinds alone. Readiness: the approach holds and a database test that fails on the base proves the fix. The only gap is the validation board check, which couldn't run.

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

@Quick104
Quick104 merged commit a7df36a into Silo-Server:main Nov 13, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Complete metadata refresh replaces podcast show and episode IDs

2 participants