Repository navigation
fix(catalog): keep titles in no library out of admin listings - #3114
Conversation
A movie whose file is renamed to another title (for example a Radarr rename that adds a TMDB tag) gets a new item on the next full scan. The old item loses its library membership but is kept for the scanner's file removal grace, so a replacement file can still relink to it. Until then an unrestricted administrator still saw it: in the unmatched-items list (with no library and no file paths to match), in search, and in browse and filter values that name no library. Listings that name no library now require the item to belong to one, as they already did for restricted viewers and for Home rows. The rule is one predicate, catalog.InSomeLibraryWhere, applied by the catalog query executor, the offset browse, browse filter values, Postgres search and its fuzzy fallback, Meilisearch hit hydration, and the unmatched-items list. Reads by ID are unchanged, and the removal grace still relinks a replacement file to the held item.
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.
|
| Layer / File(s) | Summary |
|---|---|
Catalog and search filtering internal/catalog/*, scripts/ci/db-contracts.txt, docs/architecture/missing-files.md |
Catalog browse, facets, and search now filter out items without a library association. Database tests cover catalog results, genres, search results, and hydration, including unrestricted and disabled-library access filters. |
Unmatched-item API filtering internal/api/handlers/libraries_service.go, internal/api/handlers/libraries_unmatched_ignore_db_test.go, docs/libraries-api.md |
The unmatched-items API excludes items without library membership while retaining its manga-chapter and ignored-state filters. A database test and API documentation cover the behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- [feature] Autoscan: skip the removal grace for files Sonarr/Radarr reported deleting on upgrade #3058: The listing filter does not change scanner reconciliation for stale file state during the removal grace period.
- [bug] Series or movie deleted in Sonarr/Radarr with its files stays in the library until the removal grace ends #3060: The filter does not address titles that remain matched after an Arr deletion.
- [bug] Renaming or moving a video file starts a new file row and loses its per-file state #2858: The change does not alter scanner handling of replacement files while old file records remain in the grace period.
Suggested labels: bug, go, api-v2, impact: usability, size/XL
Suggested reviewers: quick104, blurbery
Merge Risk: 
Minimal · up to 213e3
-
Listings exclude titles with no library membership, and no issue requiring a change before merge was established.
Security architecture risk: 
Low · up to 213e3
-
The change narrows which titles appear in listings without broadening permissions. Existing library restrictions and direct-access rules remain intact. Residual uncertainty concerns broader integration behavior and validation, not an identified authorization bypass.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The effective change spans media-listing consumers, including unrestricted viewers and administrators. The inspected changes reduce returned title metadata; they do not grant additional library access or mutation authority.
Trust Boundaries and Controls
- observed — Both unmatched-item HTTP routes retain acting-admin enforcement. The v1 handler accepts search and pagination inputs, not a caller-selected library authorization scope; the service adds membership eligibility unconditionally. The inspected route-to-service relationship therefore does not expose a new scope-based bypass.
Resilience and Maintainability Implications
- observed — The documented lifecycle separates hiding a title from deleting it: reconciliation removes membership, a removal grace can preserve the item for relinking, and later reconciliation can delete it. The inspected listing changes consume membership through read predicates rather than introducing a new hold, cleanup, or recovery transition.
-
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Out of Scope Changes check
-
Explanation
The changed production code, documentation, database tests, fixture updates, and CI test registration support the
#2818listing-visibility behavior. The changes do not modify unrelated scanner reconciliation or client functionality. The reported scanner follow-ups remain outside this pull request.
-
Full details: Linked Issues check
-
Explanation
The changes satisfy the listing part of
#2818. They exclude items with no library membership from catalog browse, search, filter values, and unmatched-item results, including during the retention period. The issue also requires an opened unavailable item to explain its state instead of offering a metadata refresh that cannot succeed. The PR states that reads by ID remain unchanged and makes no client or item-detail change. That requirement is not implemented or covered by an automated test.Resolution
Implement the
#2818unavailable-item detail behavior. When a retained item has no indexed playable file, show its unavailable state and do not offer the failing metadata-refresh action. Add automated coverage for this behavior.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 12 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Suggested fix: replace the placeholder with the actual evidence URL or attach the requested before-and-after captures and response excerpts. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
|
The placeholder came from the first version of the body. It now links the published page: https://evidence.siloserver.org/r/silo-server/pr-3114/ What the page has:
|
|
|
Main's Silo-Server#3114 added catalog.InSomeLibraryWhere for listings that name no library, and keeps reads by ID open for an unrestricted viewer. Use it for the audiobook listing predicates, and drop the membership check from the single GetAudiobookByID read, so progress sync for a book between a rename's two scans isn't rejected. Batch hydration for the in-progress shelf and the progress list still leave out books in no library. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Closes #2818
Related issue: N/A
Validation tasks: none (no passed case is reachable). The unmatched-items list (#198), rescans and unmatched visibility (#197), search and browse (#199) and the Series admin list (#1251) change for titles in no library; none of these tasks has a recorded result yet.
After a movie's file is renamed to point at another title, an administrator keeps seeing a broken copy of it for a day. The copy shows up in Admin → Libraries → Unmatched items with no library and no file paths to match, and in search and cross-library browse next to the real movie, without a poster. This change keeps titles that belong to no library out of those listings for every viewer, not just restricted ones.
To reproduce: scan
Atlas (2024)/Atlas (2024).mkv, which stays unmatched (local-…) because several 2024 films are called Atlas. Rename it Radarr-style toAtlas (2024) {tmdb-614933}/Atlas (2024) {tmdb-614933} [WEBDL-1080p].mkvand run a full scan. The new path gets a new, matchedmovie-tmdb-614933item. The old item loses its library membership and its file is marked missing, but reconciliation keeps it for the scanner's file removal grace (24 hours by default) so a replacement file can still relink to it. That hold is intended for arr upgrades. The listings were the problem: a viewer with no library restriction got no membership check, so the held item was listed.Approach
Listings that name no library now require the title to belong to one. Restricted viewers already had this rule, and #2695 applied it to Home rows. It is one predicate,
catalog.InSomeLibraryWhere, used by:GET /api/v2/libraries/unmatched-itemsand its frozen v1 counterpartReads by ID are unchanged, so an administrator can still open a held title from a link. The scanner and reconciliation are untouched: a replacement file that arrives within the grace still relinks to the held item with its metadata, and a full scan after the grace deletes it.
This is server-only. Web, Apple and Android clients read these endpoints and need no change. Jellyfin-protocol search shares the same search code and gets the same behavior. Two scanner problems from the report stay open as follow-ups. A file renamed to add a provider tag still gets a new item instead of rebinding to its existing
local-item. A scan scoped only to the new folder (autoscan or a webhook) leaves the old item with its membership and an unmarked file until the next full library scan.Validation
scripts/ci/db-contracts.txt: the unmatched-items list and total, search (full text, fuzzy fallback and Meilisearch hydration), and browse (cursor, offset and genre values) each leave out a title in no library and keep one in a library. Each failed onmainbefore its fix.mainthe reproduction above leaves the old Atlas in the unmatched list, in search and inGET /api/v2/catalog?type=movie. With this branch it appears in none of them, and the matched Atlas still does. Deleting a matched movie's only file, scanning, and adding a replacement file within the grace brought back the samemovie-tmdb-949item, hidden in between.go build,gofmt,go vet,make lint-changed,make lint-router-recovery,make verify-local-paths,make verify-size-ratchet,make verify-bidi,make verify-apiv2-openapi,make verify-apiv2-contract,make verify-v1-route-freeze: pass.make test-db-contracts: all 367 pass.make test-db-pins: all pass exceptTestLogPartitionsMatchPartmanOnNonUTCServer, which fails the same way onmainin the same environment.make test-go: fails onlyTestPlaybackInfoWithoutStripOrToneMapStillHasNoRouteandTestPlaybackInfoSkipsStripWhenRPUCannotBeStrippedininternal/jellycompat, which fail the same way onmain.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3114/
Surface and build: web admin Libraries page (Unmatched items) and web search for "Atlas", desktop and phone width, signed in as an administrator, local dev server with a generated test library. Before is
mainat 8b84639, after is this branch. The page also has the API responses for the unmatched list, search and cross-library browse (the web app has no page that browses movies across libraries), and the removal-grace check.Risks
An administrator no longer sees titles in no library in lists, search and filter values. Outside the removal grace, reconciliation already deletes such titles, so this only hides items that are held or under an unreachable library root. Each listing gains an
EXISTSlookup on the leadingcontent_idcolumn of themedia_item_librariesprimary key.Checklist
AI Disclosure
Note
Exclude items in no library from catalog listings, search, and unmatched items
Adds an
EXISTSpredicate on the library-membership table so items with no library membership no longer appear in catalog browse, search (full-text, fuzzy fallback, and hydration), preview pages, and the unmatched-items listing. The newInSomeLibraryWhereandappendListedLibraryAccessConditionshelpers in access_filter.go apply the predicate only when no library restrictions are given; restricted queries keep the old conditions. Reads by ID are unchanged.Macroscope summarized 213e37c.