Repository navigation
feat(metadata): improve match accuracy and localized titles - #461
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (37)
📝 WalkthroughWalkthroughThe PR adds provider-confirmed media title aliases, resumable alias backfill, alias-aware catalog search, richer metadata matching decisions, episode corroboration, alternate identity handling, stricter provider-ID parsing, and updated match-candidate presentation. ChangesMetadata matching and alias-aware search
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested labels: 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
internal/api/handlers/libraries.go (1)
1625-1639: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLog
RetryNowByFolderfailures for parity with the rest of the handler.The
SyncForFolderbranches log viaslog.ErrorContextbefore returning 500, but the twoRetryNowByFolderfailure branches return the generic 500 with no server-side log. This makes a retry-now failure undiagnosable from logs, unlike every other error path here (and unlikewakeMetadataMatcher, which warns).🪵 Add error logs
if _, err := h.SeriesMatchQueueRepo.RetryNowByFolder(r.Context(), id); err != nil { + slog.ErrorContext(r.Context(), "metadata queue: failed to retry series queue", "component", "api", "library_id", id, "error", err) writeError(w, http.StatusInternalServerError, "internal_error", "Failed to retry metadata matcher") return } @@ if _, err := h.MovieMatchQueueRepo.RetryNowByFolder(r.Context(), id); err != nil { + slog.ErrorContext(r.Context(), "metadata queue: failed to retry movie queue", "component", "api", "library_id", id, "error", err) writeError(w, http.StatusInternalServerError, "internal_error", "Failed to retry metadata matcher") return }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/api/handlers/libraries.go` around lines 1625 - 1639, In the handler’s SeriesMatchQueueRepo and MovieMatchQueueRepo RetryNowByFolder error branches, add server-side slog.ErrorContext logging before returning the existing 500 response. Include the request context, queue/failure context, library id, and error, matching the existing SyncForFolder logging style while preserving the current response behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@go.mod`:
- Line 112: Publish the github.com/Silo-Server/silo-plugin-sdk v0.11.0 tag, then
refresh dependency checksums with go mod tidy so go.sum contains the v0.11.0
entries referenced by go.mod before merging.
In `@internal/catalog/item_alias_repo_test.go`:
- Around line 72-78: Add the standard to_regclass('public.media_item_aliases')
migration skip guard at the start of
TestItemAliasRepositoryLanguageRefreshPreservesOtherLibraryLanguages, matching
the guards in TestItemAliasRepositoryReplacesOnlySuccessfulProviderAndCascades
and TestItemRepositorySearchesPersistedAliasesAcrossExactFTSAndFuzzyPaths.
Ensure the test skips before repository operations when the aliases table is
unavailable.
In `@internal/metadata/service.go`:
- Around line 1857-1880: Update the title-alias attribution flow around
mergePreferredTitleMetadata so providers implementing IdentityHintProvider are
excluded from titleAliasProviders and TitleAliases. Determine this from the
original provider instance using the p.(IdentityHintProvider) check, while
preserving normal alias attribution for other providers and retaining the
underlying metadata.
In `@migrations/sql/20260721211627_metadata_match_queue_state.sql`:
- Around line 33-35: Move idx_media_files_folder_root_active into a separate
non-transactional migration marked with -- +goose NO TRANSACTION. Create it with
CREATE INDEX CONCURRENTLY IF NOT EXISTS, and update the corresponding Down
migration to remove it using the concurrent, idempotent form.
---
Nitpick comments:
In `@internal/api/handlers/libraries.go`:
- Around line 1625-1639: In the handler’s SeriesMatchQueueRepo and
MovieMatchQueueRepo RetryNowByFolder error branches, add server-side
slog.ErrorContext logging before returning the existing 500 response. Include
the request context, queue/failure context, library id, and error, matching the
existing SyncForFolder logging style while preserving the current response
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3745b1c7-6b7d-4b27-802e-3feb0a8f228e
📒 Files selected for processing (46)
cmd/silo/main.gogo.modinternal/api/handlers/libraries.gointernal/api/handlers/libraries_match_test.gointernal/catalog/item_alias_repo.gointernal/catalog/item_alias_repo_test.gointernal/catalog/item_repo.gointernal/catalog/item_repo_test.gointernal/catalog/search_indexer.gointernal/catalog/search_indexer_test.gointernal/catalog/search_postgres_mixed.gointernal/metadata/episode_match_validation.gointernal/metadata/episode_match_validation_test.gointernal/metadata/id_consensus_test.gointernal/metadata/match_candidates.gointernal/metadata/match_candidates_test.gointernal/metadata/match_identity_fallback.gointernal/metadata/match_identity_fallback_test.gointernal/metadata/match_queue_coordinator.gointernal/metadata/match_queue_state_db_test.gointernal/metadata/match_type_diagnostics.gointernal/metadata/movie_match_queue_repo.gointernal/metadata/plugin_provider.gointernal/metadata/series_root_match_queue_repo.gointernal/metadata/service.gointernal/metadata/types.gointernal/metadata/worker.gointernal/metadata/worker_test.gointernal/models/media.gointernal/models/media_group.gointernal/naming/filename.gointernal/naming/filename_test.gointernal/naming/folderid.gointernal/naming/folderid_test.gointernal/plugins/service.gointernal/plugins/service_admin_config.gointernal/taskmanager/tasks/backfill_media_item_aliases.gointernal/taskmanager/tasks/backfill_media_item_aliases_test.gomigrations/sql/20260721211249_media_item_aliases.sqlmigrations/sql/20260721211627_metadata_match_queue_state.sqlweb/src/api/types.tsweb/src/components/MatchItemDialog.test.tsxweb/src/components/MatchItemDialog.tsxweb/src/hooks/queries/admin/libraries.tsweb/src/pages/AdminLibraries.test.tsxweb/src/pages/AdminLibraries.tsx
Quick104
left a comment
There was a problem hiding this comment.
Requesting changes after reviewing live base 5e2dd91d6bbf2824ffcc1e363943e968a890af45 against head 01132fa39bbc812717515daa7c8898c9a7dcbec0.
The seven correctness/deployment findings are attached inline: 3 P1, 3 P2, and 1 P3. The highest-risk issues are refreshes bypassing provider-ID quarantine, two-hour batch leases stranding unstarted work, and a transactional index build blocking writes to media_files during deployment.
Standards/process concerns also need resolution:
- The PR spans SDK contracts, matching, naming, queue lifecycle, search, migrations, API, and UI despite the repository's one-concern-per-PR rule.
- Movie and series queue state/reset/retry policy is substantially duplicated rather than extracted into shared logic.
- The submitted commit is not independently buildable with
GOWORK=off: SDKv0.11.0is unpublished andgo.sumlacks its checksums. This is acknowledged in the PR but remains a merge blocker. - Required verification evidence is incomplete: the body summarizes results instead of pasting real output, omits
make lint/make verify-local-pathsevidence, and includes no screenshot or recording for the UI change. - Failure outcomes/states remain raw strings across services, repositories, SQL, and API code, and
MetadataMatcherQueuesSectionshould be extracted from the already-largeAdminLibraries.tsxpage.
Validation performed against the pinned head:
- Focused Go tests passed for metadata, catalog, naming, API handlers, and task manager using exact SDK PR #11 head
443e4d6747d030ea7473a89afac4472a7b36abd6through an isolated temporary module replacement. - Focused
go vet,git diff --check, andmake verify-local-pathspassed. - Frontend: 18 focused tests, production build, ESLint, and Prettier passed.
- Normal
GOWORK=offtesting fails on the missing SDK checksums as expected. SILO_TEST_DATABASE_URLwas unset, so DB-backed queue and migration behavior was not rerun.
01132fa to
702c1ef
Compare
702c1ef to
17370c6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/metadata/worker.go`:
- Around line 838-845: Update the reparsed-file handling around
reparseQueuedFileIdentity so currentFile.BaseYear only overwrites the
provisional year when it is nonzero, matching the conditional BaseTitle and
BaseType updates while preserving the existing fallback otherwise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ffdbda10-d382-433d-bc92-deea1001f316
📒 Files selected for processing (34)
cmd/silo/main.gogo.modinternal/catalog/item_alias_repo.gointernal/catalog/item_alias_repo_test.gointernal/catalog/item_repo.gointernal/catalog/item_repo_test.gointernal/catalog/search_indexer.gointernal/catalog/search_indexer_test.gointernal/catalog/search_postgres_mixed.gointernal/metadata/episode_match_validation.gointernal/metadata/episode_match_validation_test.gointernal/metadata/id_consensus_test.gointernal/metadata/match_candidates.gointernal/metadata/match_candidates_test.gointernal/metadata/match_identity_fallback.gointernal/metadata/match_identity_fallback_test.gointernal/metadata/match_type_diagnostics.gointernal/metadata/nfo_identity_test.gointernal/metadata/plugin_provider.gointernal/metadata/service.gointernal/metadata/types.gointernal/metadata/worker.gointernal/metadata/worker_test.gointernal/models/media.gointernal/naming/filename.gointernal/naming/filename_test.gointernal/naming/folderid.gointernal/naming/folderid_test.gointernal/taskmanager/tasks/backfill_media_item_aliases.gointernal/taskmanager/tasks/backfill_media_item_aliases_test.gomigrations/sql/20260721211249_media_item_aliases.sqlweb/src/api/types.tsweb/src/components/MatchItemDialog.test.tsxweb/src/components/MatchItemDialog.tsx
🚧 Files skipped from review as they are similar to previous changes (24)
- internal/taskmanager/tasks/backfill_media_item_aliases_test.go
- go.mod
- web/src/components/MatchItemDialog.test.tsx
- internal/metadata/match_type_diagnostics.go
- internal/models/media.go
- internal/metadata/match_identity_fallback.go
- internal/metadata/plugin_provider.go
- internal/naming/folderid.go
- internal/taskmanager/tasks/backfill_media_item_aliases.go
- internal/metadata/match_identity_fallback_test.go
- internal/catalog/search_indexer_test.go
- internal/catalog/search_indexer.go
- internal/naming/folderid_test.go
- internal/naming/filename_test.go
- internal/catalog/item_repo_test.go
- web/src/components/MatchItemDialog.tsx
- internal/metadata/episode_match_validation.go
- internal/metadata/types.go
- internal/catalog/search_postgres_mixed.go
- internal/catalog/item_repo.go
- internal/metadata/match_candidates_test.go
- internal/metadata/episode_match_validation_test.go
- internal/metadata/match_candidates.go
- internal/metadata/service.go
17370c6 to
206f513
Compare
|
@Quick104 All of your findings are now addressed and the work has been split per policy:
I also completed another adversarial pass after your review and resolved the broader findings it surfaced: identity-hint alias attribution, scoped authoritative-empty aliases, duplicate-provider completeness, current-path year fallback, legacy full-metadata SDK decoding, migration test guards, and entity-specific TVDB IDs. Current verification is green for all changed packages, real-PostgreSQL alias/queue coverage, SDK/TMDB/TVDB suites, frontend lint/format/tests/build, migration validation, and changed-code lint ( Could you please re-review the core diff and the queue-specific commit in #463? |
Quick104
left a comment
There was a problem hiding this comment.
Re-reviewed the published v0.12 dependency, provider-ID trust boundary, alias snapshot replacement and deduplication, manual-match explanation UI, migration behavior, and live dev validation. All requested changes are addressed; focused and database-backed tests pass.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 24b967dfe8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for _, alias := range doc.Aliases { | ||
| variants = append(variants, alias, normalizeTitleForComparison(alias)) |
There was a problem hiding this comment.
Bump the Meilisearch schema for alias variants
When a deployment already has an active Meilisearch index, adding aliases to title_variants here does not update existing documents unless they later receive an upsert, and SearchMeilisearchSchemaVersion still stays at 3 so the provider continues accepting the old index instead of falling back or prompting a rebuild. In that setup, searches by newly supported localized/alias titles will work in Postgres but silently miss in Meilisearch for the existing catalog until every item is manually backfilled/reindexed; please force a schema mismatch/rebuild or otherwise enqueue all affected documents.
Useful? React with 👍 / 👎.
| accumulator.Title = title | ||
| accumulator.TitleLanguage = titleLanguage | ||
| accumulator.TitleIsFallback = fallback |
There was a problem hiding this comment.
Recompute sort titles when alias titles win
When a requested-language alias wins over a provider fallback title, this only replaces Title; the same provider result can still contribute its non-empty SortTitle in the following merge, and browse ordering uses sort_title before falling back to title. For providers that return a native/fallback sort title alongside an English alias, the item will display the English title but continue sorting under the native title, so clear or recompute the sort title when the preferred display title is changed this way.
Useful? React with 👍 / 👎.
| if best.evaluated { | ||
| return best | ||
| } | ||
| best.err = lastErr |
There was a problem hiding this comment.
Propagate episode validation provider errors
When a candidate has multiple episode validators, an early transient error is dropped if a later validator returns a zero-evidence success, including all-season 404s, because this returns best whenever it was evaluated and never copies lastErr. In that failure mode validateSeriesMatchByEpisodes treats the rival as successfully checked with zero evidence and can auto-promote another candidate even though the unavailable provider might have matched the local episodes; keep the error if any selected validator failed so transient provider failures don’t become negative evidence.
AGENTS.md reference: AGENTS.md:L13-L17
Useful? React with 👍 / 👎.
Part of #196.
Scope
Core metadata identity, scoring, localization, alias persistence, and manual-match explanation. Queue lifecycle and admin queue diagnostics are split into #463.
Review findings addressed
silo-plugin-sdk v0.12.0with committedgo.sumchecksums; standaloneGOWORK=offbuilds pass.internal/providerid.match_scoreandmatch_reasonsin the manual-match dialog.Dependencies and rollout
Verification
Passed on head
24b967dfe81ca604f5ec0425088df3e4616bfac8:GOWORK=off go test -count=1 ./internal/providerid ./internal/naming ./internal/catalog ./internal/metadataTestItemAliasRepository*: 8/8 against the migrated dev database, including cross-language replacement, empty complete snapshots, legacy/provider-wide isolation, and normalized deduplicationGOWORK=off go test -run '^$' ./internal/metadata ./internal/catalogpnpm --dir web run lint: 0 errors (159 existing warnings)pnpm --dir web run format:checkmake verify-local-pathsandgit diff --checkgolangci-lint: 0 issuesThe exact stacked tree containing this head was deployed to the dev LXC. API health/readiness are green, migrations applied, the alias index is valid/ready, source checksums match, and the live UI bundle contains the Match reasons rendering. Browser automation was not attached to the authenticated preview, so visual proof is covered by the deployed bundle and passing component tests.
Repository-wide
make lintstill reports 306 pre-existing findings outside this diff.AI Disclosure
Summary by CodeRabbit