Repository navigation
fix(metadata): store and show each production country once - #1996
Conversation
Series matched by both TMDB and TVDB listed their country twice, for example "countries": ["US", "US"] for Breaking Bad, so clients showed "US, US".
TMDB reports origin countries as alpha-2 ("US") and TVDB as lowercase alpha-3 ("usa"). The metadata merge treats those as different values and keeps both, and lang.CanonicalCountries then maps both to "US" without removing the repeat before the item is saved.
CanonicalCountries now drops repeats after canonicalizing, keeping the first occurrence, so refreshed items are stored with one entry per country. Rows already saved with repeats are cleaned when read: catalog item details and cards and the jellycompat ProductionLocations field pass countries through the new lang.UniqueCountries, which removes exact repeats without rewriting hand-entered values. No migration; the next metadata refresh rewrites the stored rows. Genres, studios, networks, and keywords are not canonicalized after the merge and had no repeats in the affected library.
Tests cover the canonical dedupe, the read-side helper, the TMDB plus TVDB merge into a stored item, and ProductionLocations on the jellycompat list and detail paths.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughCountry handling now removes repeated values while preserving first-occurrence order. ChangesCountry Deduplication
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Repeated country entries are removed while output fields and distinct spellings are preserved. No concrete merge-blocking risk is evident; the change is ready for normal checks. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The change removes duplicate country entries without changing response shapes, access checks, or privileges. The reviewed paths show no material security risk introduced or worsened by this PR. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Silo's pull request guidance changed today (#2016). A PR that changes what a user sees now needs before-and-after evidence in its Evidence section, and a PR with no visible change says Missing here: Before-and-after screenshots of a detail page showing the production countries line, or before-and-after excerpts of the countries field in the API response. The rules are in Show visible changes, and the PR template shows the Evidence section layout. I've converted this PR to draft for now. Mark it ready for review once the Evidence section is filled in. Generated by Claude Code |
|
The catalog item-card response also removes duplicate Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
Checked the item-card request against the wire projection. GetItemCardsByIDs builds internal ItemDetail values for the Watch Together picker, but catalogItemCardOf emits CatalogItem, which has no countries field. The change to item_cards.go therefore adds no separate visible country field to capture. The existing item-detail and Jellyfin excerpts cover the public country fields that change. |
Review summaryReviewed head: Fit: 9/10 · Readiness: 9/10 — ready No defects found. The fix stores each country once after canonicalizing and cleans rows that were already saved with repeats when they're read, so nothing needs a migration. What I checked
Known limits, none of which block merge: exact-match read cleanup won't merge spellings like Validated featuresThe Other checks
Scores
Review method: a single-pass review of the full diff and its callers, plus one independent adversarial round from a second model. Neither found any defects. AI-generated review (Claude Code, claude-opus-5-5; second round gpt-6.1-sol via Codex), posted by Quick104. |
Problem
Related issue: #1249
Validation tasks: changes Silo-Server/silo-apple#337 C2
Series matched by both TMDB and TVDB list their country twice, for example
"countries": ["US", "US"]for Breaking Bad, so clients show "US, US".TMDB reports origin countries as alpha-2 (
US) and TVDB as lowercase alpha-3 (usa). The metadata merge keeps both because they differ, andlang.CanonicalCountriesthen maps both toUSwithout removing the repeat.Approach
CanonicalCountriesdrops repeats after canonicalizing and keeps the first occurrence, so refreshed items are stored with one entry per country.ProductionLocationsfield, pass countries through the newlang.UniqueCountries. It removes exact repeats without rewriting hand-entered values.No migration; the next metadata refresh rewrites stored rows.
Validation
go build,go vet,gofmt,make lint-changed: pass.make test-go: the only failures are the hardware-acceleration, transcode and probe tests that also fail onmainon the test machine (macOS, no VAAPI, QSV or NVIDIA devices). A few timing tests that failed once while the machine was loaded passed on three reruns.make verify-settings-bindings-all, the otherverify-*targets in CONTRIBUTING, and the router artifact test: pass.ProductionLocationson the jellycompat list and detail paths.countries: ["US"], and the iPad detail page shows "US" once.The internal card detail builder also deduplicates countries, but the public CatalogItem projection used by the Watch Together picker has no countries field. There is no separate visible card-country output; the detail and Jellyfin comparisons cover the public fields.
Evidence
The web detail page does not show production countries, so these are API excerpts. The test series "Harbor Lights" was stored with
countries = ["US", "US"], as a TMDB plus TVDB merge leaves it. Same requests both times:GET <server>/api/v2/catalog/items/<Harbor Lights>Before
{ "title": "Harbor Lights", "type": "series", "countries": ["US", "US"] }After
{ "title": "Harbor Lights", "type": "series", "countries": ["US"] }Jellyfin compatibility,
GET <server>/Users/<user>/Items/<Harbor Lights>(the/Users/<user>/Items?searchTerm=Harbor&Fields=ProductionLocationslist gives the same values)Before
{ "Name": "Harbor Lights", "ProductionLocations": ["US", "US"] }After
{ "Name": "Harbor Lights", "ProductionLocations": ["US"] }Surface and build:
/api/v2/catalog/items/{id}and Jellyfin-compatProductionLocations; before c762177 (main at this PR's base), after 49501a3 (PR head). Test library with synthetic files; the duplicate countries were written directly into the test database.Risks
None identified. Genres, studios, networks and keywords are not canonicalized after the merge and had no repeats in the test library, so they are unchanged.
Checklist
AI Disclosure
mainat medium effort, checking API compatibility, behaviour, tests and commit hygiene. It checked that the read-side helper keeps nil and order and that the seed import, which also usesCanonicalCountries, is covered. No findings.Note
De-duplicate production countries across metadata and Jellyfin mappings
lang.UniqueCountrieshelper that removes exact repeated country values while keeping first-occurrence order and original spelling (lang.go)lang.CanonicalCountriesnow also collapses distinct spellings that canonicalize to the same country codeProductionLocationsin both list and detail mappingslang.CanonicalCountriesbehavior changed — it now returns only the first canonical occurrence, so existing callers that relied on duplicate canonical codes will see fewer entriesMacroscope summarized 49501a3.