Repository navigation
Conversation
Item details returned versions from every accessible library even when library_id selected one library, so the web UI showed files and media locations from libraries the viewer was not browsing. Apply the presentation library scope in FilterMediaFilesByAccess, including its unrestricted fast path, so every caller that supplies a presentation library gets narrowed results. FileAllowedByAccess stays unchanged so direct file authorization still follows access policy. Unscoped reads keep returning all accessible versions. Related issue: Silo-Server#1032 Validation: TestFilterMediaFilesByAccessPresentationLibrary failed before the change and passes after. go test passes for internal/catalog, internal/jellycompat, internal/watchtogether, and internal/audiobooks. internal/apiv2 has two failures (TestAdminResourceCapabilitiesAndScope, TestContractFixtures) that fail identically on main before this change. gofmt is clean. No web or client contract changes are needed. Harness: Codex CLI orchestrated by Claude Code Model: gpt-6-astra (xhigh) implementation; claude-fable-5-1 orchestration and review Involvement: Fully AI-generated, human verified.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesPresentation library filtering
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The library-specific media filtering change is covered without an identified current-head regression and is ready to merge after normal checks. 🚥 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 |
|
Quick104
left a comment
There was a problem hiding this comment.
The code does what the description says and the new test is honest. My concern is the premise. This turns library_id into a file-visibility filter for every caller of FilterMediaFilesByAccess, unconditionally, and that changes behavior well outside the detail page #1032 is about. I'd like a decision on the product question before this merges.
The premise
Silo merges the same movie across libraries by content ID on purpose: one item, many versions. library_id has meant "which library am I browsing" — it picks the metadata-language fallback (internal/catalog/detail.go:815) and validates item membership (internal/catalog/detail.go:1003). This makes it also decide which files exist. Four consequences worth deciding on explicitly:
- Results depend on how you got there.
web/src/pages/ItemDetail/index.tsx:167readslibraryIdfrom the URL, so it is present when you arrive from a library page or a library-scoped section and absent from Home, search, and direct links. After this change the same movie shows one version from the library grid and two from Home, with nothing in the UI explaining the difference. - The "Movies" + "Movies 4K" layout loses its point. Opening the shared title from "Movies" hides the 4K file entirely. That split-library setup is the case version merging was built for.
- The admin curation view narrows too. "Media locations" (
web/src/pages/ItemDetail/MovieContent.tsx:322,EpisodeContent.tsx:403, gated oncanCurateMetadata) exists to show every file backing an item. Scoping it by browse path removes the signal an admin needs to spot a cross-library duplicate. - It reaches playback, not just presentation.
GetWatchDetail(internal/catalog/detail.go:2890,:2947) and watch-together selection run through the same filter.internal/watchtogether/selection_resolver.go:73takesdetail.Versions[0].FileIDand:55returnsErrInvalidSelectionon an empty list, so the file a room plays now depends on whether the host's client sentlibrary_id.
The reporter isn't wrong to want per-library scoping. Both behaviors are defensible, which is the argument for making it the operator's call rather than a silent server-wide change. Options:
- A server setting under admin → Libraries, default off. Server-wide rather than per-library: an item that lives in two libraries would otherwise have two conflicting answers.
- Apply the scope at the catalog detail seam only, leaving
GetWatchDetailand watch-together on the full set, so presentation narrows but playback never loses a version. - Close #1032 as working as intended and document that versions are unified by content ID.
I'd take 1 with the default off. The current shape is the one option with no way back.
Multi-repo checklist
The body says "No web or client contract changes are needed." The wire format doesn't change, but the meaning of library_id does — on /api/v1, /api/v2, and the Jellyfin surface — so CLAUDE.md's client-visible-change checklist applies, and none of its three items is addressed:
- silo-apple / silo-android: any client sending
library_idsilently loses versions. No follow-up filed or ruled out. - jellycompat parity:
internal/jellycompat/content_direct.go:267feeds six read paths, andinternal/jellycompat/handlers_items.go:2436derives the library from the JellyfinParentIdquery parameter. In JellyfinParentIdmeans "children of this folder," not "filter this item's MediaSources," so third-party clients get behavior their target server doesn't have.internal/jellycompat/handlers_playback.go:1954passesnil, so one session sees narrowed sources in the item list and the full set at PlaybackInfo. - docs: no
docs/*-api.mdupdate describing whatlibrary_idnow does.
Separately, /api/v1 is frozen to critical fixes that keep the bridge usable. This lands there through the shared service; worth a sentence on why it qualifies, or scoping it to v2.
Optional
MediaFileAccessSQL (internal/catalog/access_filter.go:261) carries a comment that it must stay in step with its Go counterpart. That's still literally true — FileAllowedByAccess is unchanged — but there are now two file-filtering paths with different scoping rules, and internal/sections/overlay_summaries.go:55 uses the SQL one. It agrees today only because no sections caller sets PresentationLibraryID. Either mirror the scope in SQL or note in the Go comment that the scope is deliberately Go-only.
Verified
go test ./internal/catalog/... ./internal/watchtogether/... passes at 684174b. CI is green. I found no correctness defect in the diff itself; the blocker is the product decision above.
AI disclosure: review written with Claude Code, model claude-opus-5[1m].
| for _, file := range files { | ||
| if FileAllowedByAccess(file, filter) { | ||
| if FileAllowedByAccess(file, filter) && | ||
| (filter.PresentationLibraryID == nil || file.MediaFolderID == *filter.PresentationLibraryID) { |
There was a problem hiding this comment.
Putting the scope here applies it to every caller, including the two playback paths. GetWatchDetail (internal/catalog/detail.go:2890, :2947) and internal/watchtogether/selection_resolver.go both filter through this function, and the resolver takes detail.Versions[0].FileID at :73 and rejects an empty list at :55. The result is that which file actually plays depends on whether the client sent library_id, not on quality or user choice.
If the intent is presentation scoping, the catalog detail seam is the narrower place for it. See the review body for the broader question.
|
Closing this in favor of a maintainer PR that makes the scoping opt-in. The diff itself is correct and the test is good — we're carrying the test forward. The change we can't take as-is is the premise: Silo merges the same title across libraries by content ID on purpose, and an unconditional The replacement adds a server setting ( Thanks for the clear diagnosis in #1032 and the fix; it saved real time. AI disclosure: comment written with Claude Code, model |
|
Replacement is up: #1111. |
Silo merges the same title across libraries by content ID on purpose, so a detail read with library_id always listed every accessible version. Silo-Server#1032 asked for the browsed library's files only. Doing that unconditionally inside FilterMediaFilesByAccess (Silo-Server#1109) would also have narrowed playback, watch-together selection, the admin Media locations panel, and the Jellyfin ParentId reads. Add catalog.scope_versions_to_library (default false). When on, the v2 item, versions, season, and episode reads that were given a library_id return only the versions stored in that library. Playback, watch- together, and jellycompat never opt in, so an item always plays from its full version list. GET /api/v2/capabilities/catalog reports the effective value so clients know whether a version list is the whole item or one library's slice. The predicate and its table test come from Silo-Server#1109. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Problem
Related issue: #1032
GET /api/v2/catalog/items/{id}?library_id=...(and the v1 route the web client uses) returned media files from every library the profile could access, not just the one being browsed. When the same movie exists in two movie libraries, the detail page showed both versions and both media locations regardless of which library the viewer opened it from. The handler parsedlibrary_idintoAccessFilter.PresentationLibraryIDand validated membership, butFilterMediaFilesByAccessnever applied it.Approach
Apply the presentation library scope inside
FilterMediaFilesByAccess, including its unrestricted fast path, so every caller that supplies a presentation library gets narrowed results. Every current caller that sets it (catalog detail, jellycompat direct content, watch-together selection, playback) wants that narrowing; audiobooks never sets it.FileAllowedByAccessis unchanged, so direct file authorization still follows access policy and cross-library playback of an explicitly selected file keeps working. Requests withoutlibrary_idbehave exactly as before.Fixing the one filter every path routes through was smaller and safer than patching the catalog handler alone, which would have left the other scoped callers inconsistent. No web or client contract changes are needed; the web client already sends
library_id.Validation
TestFilterMediaFilesByAccessPresentationLibrary(seven cases: scoped and unscoped reads; the scope cannot bypass the allowlist, disabled libraries, quality ceiling, or a selected file outside the scope) fails onmainand passes here.go testpasses forinternal/catalog,internal/jellycompat,internal/watchtogether,internal/audiobooks.internal/apiv2has two failures (TestAdminResourceCapabilitiesAndScope,TestContractFixtures) that fail identically on untouchedmain.gofmtclean. Localgolangci-lintcould not run against the Go 1.27 toolchain (typecheck errors in the standard library), so changed-line lint is left to CI.library_id; with this build it returns only the requested library's file for eachlibrary_idand both files whenlibrary_idis omitted.Risks
Callers that set
PresentationLibraryIDnow receive fewer files when an item spans libraries. All current callers were read and want this. If an item is a member of the library but has no files there, the response has an empty version list, matching existing detail behavior. No migration or contract change.Checklist
AI Disclosure
codex exec)FilterMediaFilesByAccesscaller, checking for callers that must not be narrowed, zero-file behavior after membership validation, the fast-path change, and test gaps. No findings.Note
Fix
catalog.FilterMediaFilesByAccessto scope media versions to selectedPresentationLibraryIDPresentationLibraryIDis set,FilterMediaFilesByAccessnow requires each file'sMediaFolderIDto match that library, preventing media versions from other libraries from appearing in results.FileAllowedByAccess, allowlists, disabled-library checks, quality ceilings, andSelectedFileIDhandling) still apply on top of the library scope.SelectedFileID.PresentationLibraryIDwas set will now only see files from that library.Macroscope summarized 684174b.
Summary by CodeRabbit