Skip to content

fix(scanner): keep locked audiobook metadata through rescans - #3171

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/1253-audiobook-locked-fields
Oct 31, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
Rhainland:fix/1253-audiobook-locked-fields

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1253
Validation tasks: changes #1255 C2

An admin's correction to an audiobook doesn't last. When the book's files change, the rescan writes the file's tag title, year, genres and publisher over the item, even when an admin locked those fields. In testing, a locked title "Small Apples (Edited)" went back to "Small Apples" each time the file was touched. Metadata refreshes already honour locks; the audiobook rescan didn't.

The rescan now skips locked fields.

Approach

applyBookToMediaItem, which copies tag values onto the item for new books and changed-book rescans, checks locked_fields for the title, release dates (year and release date), genres and studios. The scanner can't import metadata.MetadataField (metadata imports scanner), so the four values are mirrored as constants; they are stored in media_items.locked_fields and can't change without a data migration.

Author and narrator credits are written separately and still follow the tags. The web admin has no audiobook editor yet (#3162), so locks are set through PATCH /api/v2/admin/items/{id}/metadata for now.

Validation

  • New table test for the four lockable fields; it failed before the fix.
  • go test ./internal/scanner/..., make lint-changed: pass.
  • Full gate on an integration build of this branch with the other Audiobooks #1253 fixes: see the summary on Audiobooks #1253.
  • Runtime: on the fix build, a locked title survived two rescans of a touched file; on the base build it reverted both times.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3171/

API excerpts from GET /api/v2/catalog/items/{id} (native API) for the same test book, on the base commit e6df1d8ed and on this branch. An admin set and locked title, year/release date, genres and publisher through PATCH /api/v2/admin/items/{id}/metadata; the book's file was then touched and the library rescanned. The file's tags say 2021, Fantasy and Fixture Press.

Field (locked) Before (e6df1d8ed) After (this branch)
Title The Chaptered Clockwork (reverted) The Chaptered Clockwork (Edited)
Year 2021 (reverted) 1999
Release date 1999-05-01 1999-05-01
Genres ["Edited Genre", "Fantasy"] (tag genre added back) ["Edited Genre"]
Publisher (studios) ["Edited Press", "Fixture Press"] (tag publisher added back) ["Edited Press"]

Risks

None identified.

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 (T3 Code)
  • Tool(s): Claude Code, Codex CLI, GitHub CLI, Playwright, Docker, ffmpeg
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Independent Claude Opus 5.5 and GPT 6.1 Sol reviews of the branch diff (correctness, repo standards, the bug as described). GPT found nothing. Opus found that the new constants separated applyBookToMediaItem from its doc comment; fixed, and both reviewers checked it. Opus also noted that a lock on credits isn't honoured on rescan; that stays out of scope here, as noted above.

Note

Fix scanner to keep locked audiobook metadata through rescans

applyBookToMediaItem in audiobook_scan.go now checks the locked-field index before applying tag-derived title, year, release date, genres, or studios. The release-dates lock covers both year and release date. Adds table-driven tests in audiobook_test.go covering locked title, release dates, genres, and studios.

  • Risk: locked-field constants mirror metadata.MetadataField; if the two lists drift, the wrong field may be skipped or overwritten.

Macroscope summarized be6391d.

When an audiobook's files changed, the rescan wrote the tag title, year,
genres and publisher over the item even if an admin had locked those fields,
so a corrected title reverted on the next scan. Skip locked fields when
applying tags, as metadata refreshes already do.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 24 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: 6efe3b01-fed1-46b4-b433-7feb633323e7
Commits

Reviewing files that changed from the base of the PR and between 62b1a6e and be6391d.

Files selected for processing: 2
  • internal/scanner/audiobook_scan.go
  • internal/scanner/audiobook_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Oct 27, 2026
@silo-kody

silo-kody Bot commented Oct 27, 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 ❌

@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The change is visible: the scanner now preserves locked audiobook metadata in item responses. The API excerpt covers the title only; please add before-and-after excerpts for the same item/request showing the changed locked-field behavior for each of these effects:

  • internal/scanner/audiobook_scan.go: year and release date.
  • internal/scanner/audiobook_scan.go: genres.
  • internal/scanner/audiobook_scan.go: publisher/studios.

Please redact any private library details from the public API excerpt.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 27, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

The Validation tasks: line overstates the impact: #1255 C2 is Not run, not failed or blocked, and #3162 says the Web admin controls needed for the full workflow are still absent. This PR changes the scanner persistence behavior C2 checks, but does not unblock the full case. Suggested line: Validation tasks: changes #1255 C2.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104

Copy link
Copy Markdown
Contributor

Reviewed be6391d408df810e3bd3c6d399d4582f9bc1fd04 against 62b1a6e82408eb4be3409255583bf8b0a192a69f.

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

I found no introduced defects. This fixes the loss of admin-locked metadata in the existing scanner path. The rescan loads the stored locks before applying tags, and the four lock IDs and field groupings match metadata refresh behavior.

Verification

  • go test -count=1 ./internal/scanner/... passed locally.
  • The new test cannot compile unchanged on the base because it references the new lock constants. With those references replaced by the equivalent stored IDs in a temporary test overlay, the table fails on the base for the title, year, genres and publisher overwrites and passes on this head. Additional temporary cases confirm that cleared, locked fields, including a missing release date, stay empty; unlocked fields still populate.
  • CI is green for the jobs that ran, including Go lint, tests, integration and database checks. Web jobs were skipped. I did not rerun the full gate or independently repeat a live rescan, device check, or inspection of the private evidence page.

Validated features

The refreshed board has no recorded passed cases. #1255 C2 covers edit persistence through rescan and is still Not run. Validation tasks: changes #1255 C2 is accurate; this review does not complete the broader Web admin case tracked with #3162.

Compatibility and manual

Apple, Android and Jellyfin clients receive the corrected values through existing catalog fields; no client or API contract change is needed. The metadata and beta audiobook manual pages need no update for honoring existing locks.

Review scope

Three Codex finders, a validation/final sweep, and one independent Claude round checked the diff, callers, persistence, contracts and lock semantics. Claude's concern about mirrored constants was checked against the stored IDs and existing catalog precedent; it does not justify a new constants-only test. Its evidence concern relied on the older bot comment: the current PR body includes excerpts for all affected fields.

Complete lock coverage remains separate work: a locked empty overview can still be filled, and an admin edit committed between the scanner's read and upsert can still lose its values. Both paths predate this PR. Author and narrator credits are explicitly excluded from this fix.

Note

AI-generated review by gpt-6.1-sol in T3 Code using the Codex provider. Independent source review: claude-opus-5-5 through T3 Code's Claude provider, one round at high effort. Tools: GitHub CLI and local Go test harnesses. No human acceptance validation is claimed.

@Quick104
Quick104 merged commit 53e2a7a into Silo-Server:main Oct 31, 2026
16 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 evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants