Skip to content

fix(metadata): store each library's language in shared-item localizations - #2677

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/2618-localized-overview-language
Oct 21, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/2618-localized-overview-language

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2618
Related issue: N/A
Validation tasks: none (no passed case reaches this code; #1250, #1213, #1215 and #1210 cover this area but have no passed case yet)

When a movie or series is in both an English and a French library, the French library shows the English description. The French localization row holds a copy of the English text, and Refresh All Metadata writes the same copy again, so the row never heals. Titles that are only in the French library are not affected.

This change makes the second library's refresh store text in that library's language. A Refresh All repairs the rows that are already wrong, with no migration or manual cleanup.

A shared title has one catalog item, whose canonical text is in the language of the library that matched it first. When the other library refreshes it, mergeAndPersist merges the stored item into the fetched result. The localization row was then built from that merged result, so it got the canonical title, overview and tagline under req.Language, labelled overview_source = provider.

Approach

  • The localization write uses the text fetched in the request language. A locked title or overview still writes the canonical value, as before. The canonical item and its default_metadata_language are not changed.
  • If the provider marks its title as a fallback (the original title, because it has none in that language), the row keeps the title it already has or stays empty and shows the base title.
  • A stored provider value that is identical to the base item's text is treated as a copy. A refresh replaces it in both scheduled (fill-empty) and manual refreshes. If the provider has no translation for that field, MediaItemLocalizationRepository.Upsert clears the copy. The field then shows the base text (no visible change), and AI translation can fill it; before, the copy blocked AI translation because the field never looked empty.
  • Manual text is never touched, AI text keeps its current refresh behavior, and an empty provider value still never erases a real translation.
  • A scheduled refresh that can't read the item's NFO skips the copy repair, so values the NFO set stay even where they match the base text.

This is server-only and changes no API contract. Native API and jellycompat responses read the same localization rows, so clients show the corrected text after a refresh with no client change. Season and episode localizations were already built from provider-only results and are unchanged.

Validation

  • Unit tests cover the cases the issue asks for: both scan orders in every refresh mode, repair of an existing copied row with and without a provider translation, kept provider, AI and manual text, field locks, and fallback titles. They fail on main.
  • A database test covers the upsert clearing rule. It is listed in scripts/ci/db-contracts.txt, so CI runs it.
  • go test ./internal/metadata/... ./internal/catalog/... passes, with the database tests run against local Postgres. make lint-changed reports 0 issues.
  • End to end against real TMDB:
    • A build of main reproduced the bug: the shared titles' fr rows held the exact English overview, and Refresh All rewrote it.
    • On this branch, Refresh All replaced the copies with TMDB's French text.
    • The canonical language stayed en, the English library still shows English, and a French-only title is unchanged.
    • French-first scanning stores English in the en row.
    • Library default and explicit French profile settings both show French.
    • A manual French overview survived the refresh.
  • Not tested end to end: a provider with no French text for a copied field. TMDB had French text for every test title, so only the database test covers clearing.

Evidence

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

Surface and build: web item detail page opened from the French libraries (Library default profile language), desktop and mobile web. Before: a build of main (a434bbc) after Refresh All. After: this branch after Refresh All on the same data.

Risks

  • The repair compares the stored localized text with the item's current base text. A copy made before the base text later changed stays until the provider supplies a translation for that field.
  • A provider-sourced localized title equal to the canonical title is now dropped when the provider has no non-fallback title, so it shows the identical base title.
  • No migration. Existing rows are repaired the next time an admin runs Refresh All for the affected libraries.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code agent; Codex CLI (second reviewer)
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review only)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: independent reviews of the full branch diff by claude-opus-5-5 and gpt-6.1-sol, with findings checked against the code. GPT reported none. Opus reported one low finding: a provider fallback title (the original-script title) would override the readable base title. It was confirmed and fixed with a test.

Note

Fix shared-item localizations to store each library's language text

  • Non-canonical localization rows now build from text fetched in the requested language via localizedItemText in service.go, with locked fields using canonical item text and fallback titles omitted.
  • buildItemLocalizationRecord clears existing provider-sourced title, sort-title, overview, and tagline values that are exact copies of canonical text, so they no longer display as translations. Manual values and real translations are preserved.
  • MediaItemLocalizationRepository.Upsert in localization_repo.go also clears provider overview/tagline values equal to base text when the incoming provider value is empty.
  • The unreadable-local-metadata marker now applies to localization persistence regardless of local artwork handling, preventing refreshes from clearing values sourced from an unreadable NFO.
  • Behavioral Change: existing localization rows containing copied canonical text are cleared on refresh in both the metadata service and the catalog upsert; see clearCanonicalCopy and the new SQL branches in Upsert.

Macroscope summarized 3668229.

…ions

A title shared between libraries in two languages stored the canonical
(first library's) text in the second language's localization row. A
non-canonical refresh merges the stored canonical item into its result,
and the localization write then took its title, overview and tagline
from that merged result instead of the text fetched in the request
language. Refresh All rewrote the same copy, so the rows never healed.

The localization write now uses the text fetched in the request
language; a locked field still keeps the canonical value. A stored
provider value identical to the canonical text is treated as a copy:
the refresh replaces it in either merge mode, and when the provider has
no translation the upsert clears it so the field falls back to the base
text and AI translation can fill it. Manual and AI text is untouched.

Closes Silo-Server#2618
@silo-kody

silo-kody Bot commented Oct 18, 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 the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 18, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 18, 2026

Copy link
Copy Markdown

The PR changes shared-item detail pages: localized titles, overviews, and taglines can now reflect the requesting library’s language instead of copied canonical-language text (internal/metadata/service.go, internal/catalog/localization_repo.go). The Evidence section says a link will follow but contains no captures or evidence link. Please add before-and-after captures of the same shared item on the affected detail page, with the surface and build/commit identified; include both desktop and mobile web captures. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 539c4c60-4ab4-4969-8e45-d99cc2de286e
📥 Commits

Reviewing files that changed from the base of the PR and between f255779 and 3668229.

📒 Files selected for processing: 4
  • internal/metadata/item_localization_text_test.go
  • internal/metadata/local_artwork_precedence.go
  • internal/metadata/service.go
  • scripts/ci/db-contracts.txt

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7eb5684a-abc4-4e0a-af63-0e54512bc30f
📥 Commits

Reviewing files that changed from the base of the PR and between a434bbc and f255779.

📒 Files selected for processing: 6
  • internal/catalog/localization_repo.go
  • internal/catalog/localization_upsert_test.go
  • internal/metadata/fallback_unification_test.go
  • internal/metadata/item_localization_text_test.go
  • internal/metadata/local_image_source_test.go
  • internal/metadata/service.go

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

📝 Walkthrough

Non-canonical metadata refreshes now retain fetched language-specific text separately from merged canonical metadata. Localization records filter fallback titles and account for locked fields. Upserts clear copied canonical text under source-specific conditions while preserving other existing values.

Changes: Localized metadata refresh

Layer / File(s) Summary
Capture and persist request-language text
internal/metadata/service.go, internal/metadata/item_localization_text_test.go, internal/metadata/fallback_unification_test.go, internal/metadata/local_image_source_test.go
Non-canonical writes capture fetched text before the canonical merge. Localization-record construction receives filtered localized text and merged canonical metadata. Tests cover scan order, refresh mode, fallback titles, locks, and preservation of canonical item data.
Clear copied text during localization upsert
internal/catalog/localization_repo.go, internal/catalog/localization_upsert_test.go
Upserts clear copied overview and tagline values when the incoming value is empty and the stored source is provider. The database test checks clearing and preservation of provider, AI, and manual values.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant MetadataService
  participant localizedItemText
  participant buildItemLocalizationRecord
  participant metadataItemLocalizationRepo
  MetadataService->>localizedItemText: Filter fetched text using fallback and lock state
  MetadataService->>buildItemLocalizationRecord: Pass localized text and merged canonical metadata
  MetadataService->>metadataItemLocalizationRepo: Upsert localization record
Loading

Suggested reviewers: quick104

Merge Risk: ⚪ Minimal · up to f2557

The localized refresh change is mergeable after normal checks; no actionable issue remains from this review.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2618 requires independent localized metadata, repair of copied provider values, preservation of canonical identity, locks, manual text, AI text, and fallback behavior. The service changes and t… Add reviewable automated regression cases for movie items and French-only items. Cover both scan orders and the existing refresh and preservation cases, or identify existing tests that provide this coverage.
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Out of Scope Changes check Passed The changes stay within issue #2618. The repository upsert rule repairs copied localization values, the metadata interface supports focused localization tests, and the tests cover the refresh behavior…
Title check Passed The title clearly and concisely describes the main change: storing each library's language in shared-item localizations.
Description check Passed The description directly explains the shared-item localization bug, implementation, testing, risks, and expected behavior.
Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2618. The repository upsert rule repairs copied localization values, the metadata interface supports focused localization tests, and the tests cover the refresh behavior. No unrelated API, season, episode, or web profile changes are present.

Full details: Linked Issues check

Explanation

Issue #2618 requires independent localized metadata, repair of copied provider values, preservation of canonical identity, locks, manual text, AI text, and fallback behavior. The service changes and the added tests support these behaviors. However, the added regression tests exercise only a shared series item. They do not establish the issue's requested movie and French-only coverage. The reported end-to-end checks do not replace reviewable automated regression coverage.

Resolution

Add reviewable automated regression cases for movie items and French-only items. Cover both scan orders and the existing refresh and preservation cases, or identify existing tests that provide this coverage.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 18, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 18, 2026

Copy link
Copy Markdown

Major change: the recorded Server results for #1213 C1–C2 and Web results for #1215 C1–C2 cover profile-language display and AI-on-view. This PR changes the provider-localization write/clear path, changing displayed fields for shared items and whether copied fields are considered missing for AI. The PR must explain why the previously recorded behavior changes; these cases need re-validation after merge.

The issue comments record these outcomes on bf63b3d22 with fixes #2207–#2214; they are pre-RC rehearsal results, not RC certification. #1250 C2 is still Not run, #197 has no numbered Results, and #1210 C2's canonical-language refresh run does not exercise the new noncanonical localization path.

Suggested fix: Validation tasks: changes #1213 C1-C2, #1215 C1-C2

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

Posted via Macroscope — v1 validation impact

@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 f255779. The approach holds up: building the localization row from the text fetched before the merge is the right boundary, and it matches how season and episode localizations already work. I found two issues. Both are small, and I'm fixing both in commits on this branch, so there's no need to change anything yourself.

Comment thread internal/metadata/service.go Resolved
Quick104 and others added 2 commits October 21, 2026 11:55
CI skips database tests that no list selects.

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

A fill-empty refresh carries on when it cannot read the NFO, on the grounds
that it leaves stored values alone. The canonical-copy repair broke that: it
cleared stored NFO values that match the canonical text, and the provider's
text filled them. Skip the repair on such a pass, and record the unreadable
sidecar in the context whether or not local artwork caching is on.

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

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 3668229 (the original f255779 plus two review fixes I pushed).

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

Fit. This fixes a real bug in the core experience. A shared title showed the first library's language in the second library, and Refresh All couldn't repair it. The fix is in the right place: the localization row is built from the text fetched in the request language, which is how season and episode localizations already work. It adds no setting, API field, or migration.

Readiness. The core tests fail on the base. TestSecondLibraryStoresItsOwnLanguageText and TestRefreshRepairsLocalizationHoldingCanonicalCopy don't build on main as written, so I ran them there with only the repository-interface change applied (no behavior change). Both fail with the copied English text, as the issue describes. TestProviderUpsertClearsCopiedBaseTextOnly fails on the base and passes on the head against a freshly migrated Postgres 18. I did not repeat the end-to-end TMDB run described in the PR body.

Addressed findings

  • NFO text replaced while the sidecar is unreadable (medium). A scheduled refresh that couldn't read the NFO cleared stored NFO values that matched the canonical text, and the provider's text took their place. Fixed in 3668229: the copy repair is skipped on such a pass. TestLocalizationKeepsNFOTextWhenSidecarUnreadable failed on f255779 and passes now.
  • The new database test wasn't in a CI list (low). Fixed in 21ab6d9 by adding it to scripts/ci/db-contracts.txt.

Remaining for the maintainers

Nothing blocks the merge. Two low-impact limits stay, and both match the PR's Risks section:

  • A copy made before the base text changed isn't recognized as a copy. It stays until the provider supplies a translation for that field.
  • If a canonical refresh changes the base text between the localization read and the upsert, the SQL clearing rule misses the copy. A later refresh repairs it.

Other feedback

  • Macroscope's evidence comment predates the evidence link; the PR now carries one. My fixes only change the unreadable-NFO path, so the published captures still match.
  • Macroscope's validation comment says AI metadata translation — Server #1213 C1–C2 and AI metadata translation — Web #1215 C1–C2 have recorded results. The board shows them as not run. I changed the Validation tasks: line to none because no passed case reaches this code.

Validated features

No passed case on the v1.0 board reaches this diff. The only passed cases are the person and cast tasks (#1138, #1143), and they don't read item localizations. Validation tasks: none.

User manual and clients

  • User manual: unaffected. The preferences page says the metadata language sets titles and descriptions; this fix makes that true for shared titles.
  • Apple and Android: no change needed. The fix is server-only, and clients read the corrected rows through the existing APIs.
  • jellycompat: it reads the same localization rows, so it gets the fix too.

Method

Multi-agent review at medium effort (three finders and a validation check on Claude Opus 5.5 and Sonnet), plus one adversarial round by GPT-6.1-Sol, which raised the NFO finding.

@silo-kody

silo-kody Bot commented Oct 21, 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 21, 2026

Copy link
Copy Markdown

The linked evidence covers desktop and mobile web only, while the PR also changes item metadata returned through the native API and jellycompat for clients that render it. Please add before-and-after captures of the same shared item in each affected native and Jellyfin-compatible client surface, with the surface and build or commit identified; the captures should show the requested-language title, overview, and tagline replacing copied canonical-language text. Suggested fix: No diff — add these captures under ## Evidence.

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

Posted via Macroscope — Visible change evidence

@Quick104
Quick104 merged commit e8ec984 into Silo-Server:main Oct 21, 2026
20 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 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] Shared English/French libraries save English descriptions in French localization rows

2 participants