Repository navigation
feat(jellycompat): BoxSet collections, genre-by-name, and airtight ABS media exclusion - #115
Conversation
…-by-name
- Audiobook libraries (type 'audiobooks'/'audiobook') no longer appear in
Views/VirtualFolders, and all browse/search/genre/detail paths are clamped
to movie/series/episode so audiobook items cannot leak or stream through
the Jellyfin compat surface (they are served by the ABS-compat API).
- Library collections are now exposed as Jellyfin BoxSets:
IncludeItemTypes=BoxSet listing (optionally scoped via ParentId library),
/Items/{id} BoxSet detail, ParentId children with curated position order
preserved (explicit SortBy delegates to catalog ordering), poster/backdrop
presigning, and visibility + library-access filtering.
- /Items with only unexposable IncludeItemTypes (e.g. Playlist) returns an
empty result instead of falling through to views/browse.
- New GET /Genres/{name} endpoint resolving canonical genre casing.
Co-Authored-By: Claude Fable 5 <[email protected]>
…e cases from review - Add catalog.AccessFilter.ExcludedMediaTypes, enforced by applyAccessFilter and threaded through Search/GetByIDsWithAccess/EnsureAccessible and BrowseFavorites. The compat layer stamps audiobook+podcast exclusions onto every resolved access filter (one wrap in withDefaults), closing the favorites, recommendations, and item-image leak paths that per-call-site guards missed. - Treat podcast libraries like audiobook libraries: hidden from Views, items excluded everywhere (they're served by the ABS-compat API). - HandleItems: BoxSet listing no longer hijacks user-state-filtered queries (IncludeItemTypes=BoxSet&Filters=IsFavorite returns empty again), IncludeItemTypes=CollectionFolder returns library views as before, and Ids=<boxsetId> re-hydrates the BoxSet DTO instead of falling through to the views response. - BoxSet artwork is now durable: stable signed tags seeded from the artwork key (no churn on presign rotation) plus a collections fallback in the images handler, so posters survive restarts and cache expiry. - BoxSet listing filters/sorts/pages the lightweight collection rows before building DTOs, so a Limit=24 page over 300 collections no longer presigns ~600 posters per request; collection children also page before hydrating user state. - Dedupe: shared loadVisibleCollection guard, shared collection-page writer, single scoped-types implementation, emptyQueryResult helper. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR extends Jellyfin compatibility and catalog layers to hide audiobooks/podcasts from the Jellycompat surface and introduces full BoxSet (collection) support, including listing, detail retrieval, member hydration, artwork serving, and genre endpoints. ChangesMedia-Type Exclusion Infrastructure
Collection/BoxSet Support
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
internal/jellycompat/handlers_collections.go (1)
60-63: 💤 Low valuePotential silent error swallowing on collection lookup.
When
GetByIDreturns a non-nil error (e.g., database connection failure), this returns(nil, nil)which callers interpret as "collection not found." Transient failures would be masked as 404s.Consider distinguishing not-found from actual errors:
♻️ Suggested change
func (h *ItemsHandler) loadVisibleCollection(ctx context.Context, session *Session, collectionID string) (*models.LibraryCollection, error) { if h.collections == nil { return nil, nil } collection, err := h.collections.GetByID(ctx, collectionID) + if err != nil { + return nil, err + } - if err != nil || collection == nil { + if collection == nil { return nil, nil }🤖 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/jellycompat/handlers_collections.go` around lines 60 - 63, The current GetByID handling swallows real errors by returning (nil, nil) whenever err != nil or collection == nil; change the logic in the handler so that if h.collections.GetByID(ctx, collectionID) returns a non-nil error you return that error (e.g., return nil, err), and only return (nil, nil) when err == nil and collection == nil (meaning truly not found); update the branch around h.collections.GetByID to first check err and propagate it, then handle the nil-collection not-found case.internal/jellycompat/audiobook_exclusion_test.go (1)
12-31: ⚡ Quick winAdd regression cases for pre-populated exclusions and non-video explicit types.
These tests currently miss two boundary cases: base resolver already returning
ExcludedMediaTypes, and explicit non-video types reducing tocompatNoMatchType. Adding both will lock in the exclusion boundary.Also applies to: 60-84
🤖 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/jellycompat/audiobook_exclusion_test.go` around lines 12 - 31, Add two regression cases to TestCompatScopedTypes: (1) a case where the input is already the exclusion sentinel (compatNoMatchType) and the expected output remains compatNoMatchType to cover the "pre-populated ExcludedMediaTypes" boundary, and (2) a case with only non-video explicit types (e.g., "audiobook,podcast") expecting compatNoMatchType so explicit non-video lists collapse to the exclusion sentinel; update the cases slice in TestCompatScopedTypes that exercises compatScopedTypes to include these two entries (refer to compatScopedTypes and compatNoMatchType).
🤖 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/jellycompat/content_direct.go`:
- Around line 80-84: withCompatAccessExclusions currently replaces
ExcludedMediaTypes only when empty, which fails to enforce
compatExcludedMediaTypes if the base filter already has entries; update
withCompatAccessExclusions to merge/union compatExcludedMediaTypes into
filter.ExcludedMediaTypes (referencing withCompatAccessExclusions,
catalog.AccessFilter.ExcludedMediaTypes, and compatExcludedMediaTypes),
appending any missing values and removing duplicates so existing exclusions are
preserved and "audiobook"/"podcast" are always enforced.
- Around line 108-124: compatScopedSearchTypes currently accepts any
non-excluded explicit type and can pass unsupported/non-video types downstream;
change it to clamp explicit types to the allowed video set: build a lookup from
compatVideoTypeList and, after normalizing each input
(strings.ToLower/TrimSpace), only keep types that exist in that lookup; if the
intersection is empty return []string{compatNoMatchType}, otherwise return the
intersected list — this keeps compatScopedSearchTypes (and callers like
compatScopedTypes) from forwarding unsupported types.
---
Nitpick comments:
In `@internal/jellycompat/audiobook_exclusion_test.go`:
- Around line 12-31: Add two regression cases to TestCompatScopedTypes: (1) a
case where the input is already the exclusion sentinel (compatNoMatchType) and
the expected output remains compatNoMatchType to cover the "pre-populated
ExcludedMediaTypes" boundary, and (2) a case with only non-video explicit types
(e.g., "audiobook,podcast") expecting compatNoMatchType so explicit non-video
lists collapse to the exclusion sentinel; update the cases slice in
TestCompatScopedTypes that exercises compatScopedTypes to include these two
entries (refer to compatScopedTypes and compatNoMatchType).
In `@internal/jellycompat/handlers_collections.go`:
- Around line 60-63: The current GetByID handling swallows real errors by
returning (nil, nil) whenever err != nil or collection == nil; change the logic
in the handler so that if h.collections.GetByID(ctx, collectionID) returns a
non-nil error you return that error (e.g., return nil, err), and only return
(nil, nil) when err == nil and collection == nil (meaning truly not found);
update the branch around h.collections.GetByID to first check err and propagate
it, then handle the nil-collection not-found case.
🪄 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: c17b0e79-3e72-4d2b-84c9-15594380e8b7
📒 Files selected for processing (15)
internal/catalog/access_filter.gointernal/catalog/favorites_browse.gointernal/catalog/item_repo.gointernal/jellycompat/audiobook_exclusion_test.gointernal/jellycompat/auth_test.gointernal/jellycompat/content_direct.gointernal/jellycompat/handlers_collections.gointernal/jellycompat/handlers_collections_test.gointernal/jellycompat/handlers_genres_test.gointernal/jellycompat/handlers_images.gointernal/jellycompat/handlers_items.gointernal/jellycompat/idcodec.gointernal/jellycompat/query.gointernal/jellycompat/router.gointernal/jellycompat/userdata_direct.go
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1555f073c
ℹ️ 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".
| collection, err := h.collections.GetByID(r.Context(), collectionID) | ||
| if err != nil || collection == nil { | ||
| writeError(w, http.StatusNotFound, "NotFound", "Item not found") | ||
| return | ||
| } | ||
| imageURL := h.presignCollectionArtwork(r.Context(), collectionArtworkKey(collection, imageType)) |
There was a problem hiding this comment.
Check collection visibility before serving artwork
When an authenticated user requests /Items/{boxSetId}/Images/Primary without a valid image tag, this path loads the collection directly and serves its artwork without applying the same loadVisibleCollection/collectionVisible checks used by /Items/{id} and BoxSet listings. For collections in hidden libraries or libraries outside the user's access scope, knowing or retaining the encoded collection ID is enough to retrieve the poster/backdrop even though the collection detail correctly 404s; pass the session through and reuse the visibility check before presigning the artwork.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 60eb786 — handleCollectionImage now applies the same rules as the BoxSet item endpoints: visibility must be 'visible' and the collection must intersect the session's visible libraries (via the shared visibleLibraryIDSet helper), otherwise 404. The tag path is unchanged by design: tags are only signed for collections served by the visible listing.
| // Favorites are shared with the ABS surface; its media types are | ||
| // never exposed here (they would 404 on detail/PlaybackInfo). | ||
| if isCompatExcludedMediaType(mi.Type) { | ||
| continue |
There was a problem hiding this comment.
Filter favorites before applying pagination
When a user has audiobook/podcast favorites mixed with video favorites, this filter runs after store.ListFavorites has already applied the requested raw limit/offset window, while handleFavoriteItems later treats the filtered slice as the visible result set. In that case later favorites pages can under-fill or go empty even though enough video favorites exist after the skipped ABS entries; the exclusion needs to happen in the favorites query/window, or the caller needs to keep fetching until it has enough visible items.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 60eb786 — ListFavorites now over-fetches the raw favorite rows (2x window, min 200, capped 10000), filters ABS-surface types, rebuilds favorite order, and only then applies the offset/limit window — so pages no longer shrink or shift. Artwork is presigned only for the returned page.
| collection, err := h.collections.GetByID(ctx, collectionID) | ||
| if err != nil || collection == nil { | ||
| return nil, nil |
There was a problem hiding this comment.
Propagate collection lookup errors
If the collection repository returns a database or other upstream error here, loadVisibleCollection treats it the same as a missing collection and the handlers return 404/empty results. During a transient DB failure or query error this masks the outage as “not found,” causing clients to drop or cache missing BoxSets instead of retrying; only the not-found case should be swallowed, and other errors should be returned to writeCompatUpstreamError.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 60eb786 — loadVisibleCollection (and the images-handler lookup) now map only catalog.ErrLibraryCollectionNotFound to not-found; any other repo error propagates to writeCompatUpstreamError so transient DB failures surface as 5xx instead of 404/empty.
- withCompatAccessExclusions merges compat exclusions with any the base resolver already supplies instead of conditionally skipping them. - Explicit type filters clamp to a closed allowlist (movie/series/episode/ season) rather than passing unknown types through to catalog queries. - Collection artwork on the session path applies the same visibility rules as the BoxSet item endpoints (hidden or inaccessible-library collections 404 instead of serving posters). - loadVisibleCollection propagates infrastructure errors instead of masking transient DB failures as 404/empty; only ErrLibraryCollectionNotFound maps to not-found. - ListFavorites filters ABS-surface favorites before applying the limit/offset window (over-fetching the raw rows) so pages don't shrink or shift, and presigns artwork only for the returned page. Co-Authored-By: Claude Fable 5 <[email protected]>
…S media exclusion (#115) * feat(jellycompat): exclude audiobook libraries, add BoxSets and genre-by-name - Audiobook libraries (type 'audiobooks'/'audiobook') no longer appear in Views/VirtualFolders, and all browse/search/genre/detail paths are clamped to movie/series/episode so audiobook items cannot leak or stream through the Jellyfin compat surface (they are served by the ABS-compat API). - Library collections are now exposed as Jellyfin BoxSets: IncludeItemTypes=BoxSet listing (optionally scoped via ParentId library), /Items/{id} BoxSet detail, ParentId children with curated position order preserved (explicit SortBy delegates to catalog ordering), poster/backdrop presigning, and visibility + library-access filtering. - /Items with only unexposable IncludeItemTypes (e.g. Playlist) returns an empty result instead of falling through to views/browse. - New GET /Genres/{name} endpoint resolving canonical genre casing. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(jellycompat): centralize ABS media-type exclusion, fix BoxSet edge cases from review - Add catalog.AccessFilter.ExcludedMediaTypes, enforced by applyAccessFilter and threaded through Search/GetByIDsWithAccess/EnsureAccessible and BrowseFavorites. The compat layer stamps audiobook+podcast exclusions onto every resolved access filter (one wrap in withDefaults), closing the favorites, recommendations, and item-image leak paths that per-call-site guards missed. - Treat podcast libraries like audiobook libraries: hidden from Views, items excluded everywhere (they're served by the ABS-compat API). - HandleItems: BoxSet listing no longer hijacks user-state-filtered queries (IncludeItemTypes=BoxSet&Filters=IsFavorite returns empty again), IncludeItemTypes=CollectionFolder returns library views as before, and Ids=<boxsetId> re-hydrates the BoxSet DTO instead of falling through to the views response. - BoxSet artwork is now durable: stable signed tags seeded from the artwork key (no churn on presign rotation) plus a collections fallback in the images handler, so posters survive restarts and cache expiry. - BoxSet listing filters/sorts/pages the lightweight collection rows before building DTOs, so a Limit=24 page over 300 collections no longer presigns ~600 posters per request; collection children also page before hydrating user state. - Dedupe: shared loadVisibleCollection guard, shared collection-page writer, single scoped-types implementation, emptyQueryResult helper. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(jellycompat): address PR review comments - withCompatAccessExclusions merges compat exclusions with any the base resolver already supplies instead of conditionally skipping them. - Explicit type filters clamp to a closed allowlist (movie/series/episode/ season) rather than passing unknown types through to catalog queries. - Collection artwork on the session path applies the same visibility rules as the BoxSet item endpoints (hidden or inaccessible-library collections 404 instead of serving posters). - loadVisibleCollection propagates infrastructure errors instead of masking transient DB failures as 404/empty; only ErrLibraryCollectionNotFound maps to not-found. - ListFavorites filters ABS-surface favorites before applying the limit/offset window (over-fetching the raw rows) so pages don't shrink or shift, and presigns artwork only for the returned page. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
…S media exclusion (#115) * feat(jellycompat): exclude audiobook libraries, add BoxSets and genre-by-name - Audiobook libraries (type 'audiobooks'/'audiobook') no longer appear in Views/VirtualFolders, and all browse/search/genre/detail paths are clamped to movie/series/episode so audiobook items cannot leak or stream through the Jellyfin compat surface (they are served by the ABS-compat API). - Library collections are now exposed as Jellyfin BoxSets: IncludeItemTypes=BoxSet listing (optionally scoped via ParentId library), /Items/{id} BoxSet detail, ParentId children with curated position order preserved (explicit SortBy delegates to catalog ordering), poster/backdrop presigning, and visibility + library-access filtering. - /Items with only unexposable IncludeItemTypes (e.g. Playlist) returns an empty result instead of falling through to views/browse. - New GET /Genres/{name} endpoint resolving canonical genre casing. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(jellycompat): centralize ABS media-type exclusion, fix BoxSet edge cases from review - Add catalog.AccessFilter.ExcludedMediaTypes, enforced by applyAccessFilter and threaded through Search/GetByIDsWithAccess/EnsureAccessible and BrowseFavorites. The compat layer stamps audiobook+podcast exclusions onto every resolved access filter (one wrap in withDefaults), closing the favorites, recommendations, and item-image leak paths that per-call-site guards missed. - Treat podcast libraries like audiobook libraries: hidden from Views, items excluded everywhere (they're served by the ABS-compat API). - HandleItems: BoxSet listing no longer hijacks user-state-filtered queries (IncludeItemTypes=BoxSet&Filters=IsFavorite returns empty again), IncludeItemTypes=CollectionFolder returns library views as before, and Ids=<boxsetId> re-hydrates the BoxSet DTO instead of falling through to the views response. - BoxSet artwork is now durable: stable signed tags seeded from the artwork key (no churn on presign rotation) plus a collections fallback in the images handler, so posters survive restarts and cache expiry. - BoxSet listing filters/sorts/pages the lightweight collection rows before building DTOs, so a Limit=24 page over 300 collections no longer presigns ~600 posters per request; collection children also page before hydrating user state. - Dedupe: shared loadVisibleCollection guard, shared collection-page writer, single scoped-types implementation, emptyQueryResult helper. Co-Authored-By: Claude Fable 5 <[email protected]> * fix(jellycompat): address PR review comments - withCompatAccessExclusions merges compat exclusions with any the base resolver already supplies instead of conditionally skipping them. - Explicit type filters clamp to a closed allowlist (movie/series/episode/ season) rather than passing unknown types through to catalog queries. - Collection artwork on the session path applies the same visibility rules as the BoxSet item endpoints (hidden or inaccessible-library collections 404 instead of serving posters). - loadVisibleCollection propagates infrastructure errors instead of masking transient DB failures as 404/empty; only ErrLibraryCollectionNotFound maps to not-found. - ListFavorites filters ABS-surface favorites before applying the limit/offset window (over-fetching the raw rows) so pages don't shrink or shift, and presigns artwork only for the returned page. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
Problem
The Jellyfin compat API was missing endpoints clients use for browsing, and leaked ABS-surface content:
IncludeItemTypes=BoxSetfell through to a full library browse, and collection IDs were unaddressable./Genres/{name}was unregistered.What changed
BoxSets —
LibraryCollectionis now exposed as Jellyfin BoxSets:IncludeItemTypes=BoxSetlisting (optionally scoped byParentIdlibrary, with SearchTerm/NameStartsWith/SortName support),/Items/{id}detail,ParentId={boxset}children preserving curated position order (explicitSortBydelegates ordering/paging to catalog),Ids=re-hydration, and durable artwork (stable signed tags from the artwork key + a collections fallback in the images handler, so posters survive restarts and presign rotation). Listing filters/sorts/pages the lightweight rows before building DTOs, so aLimit=24page over hundreds of collections doesn't presign every poster.ABS media exclusion — implemented at the access-filter layer rather than per endpoint:
catalog.AccessFiltergainedExcludedMediaTypes, enforced byapplyAccessFilterand threaded throughSearch,GetByIDsWithAccess,EnsureAccessible, andBrowseFavorites. The compat router stampsaudiobook+podcastexclusions onto every resolved filter in one place (withDefaults), so favorites, recommendations, images, and future data paths inherit the exclusion. Audiobook/podcast libraries are hidden from Views/VirtualFolders, and browse/genre listings clamp to video types.Dispatch correctness —
/Itemsrequests whoseIncludeItemTypesmap to nothing exposable return empty instead of falling through to views/browse;CollectionFolderstill returns library views; BoxSet listings don't hijackFilters=IsFavorite/IsResumable/IsPlayedqueries (they return empty, matching prior behavior).Genres —
GET /Genres/{name}resolves canonical casing scoped to the caller's visible libraries;GenreIds=/ParentIdfiltering verified covered by existing paths.Why this approach
A review pass on the first commit found the per-call-site exclusion pattern had already missed three paths (favorites, recommendations, item images) within the same PR — moving the exclusion into
AccessFiltermakes it structural instead of a convention every new endpoint must remember.Testing
Ids=re-hydration, user-state-filtered BoxSet queries, CollectionFolder views, unmapped-type empty results, type-scope clamps, hidden-library exclusion, access-filter wrapper,/Genres/{name}../internal/...suite green;go vet+ gofmt clean.make dev-deploy) and verified on an Nvidia Shield Jellyfin client: audiobook library hidden, collections/genres browsable, streaming intact.Risks / follow-ups
IncludeItemTypes=Movie,BoxSetdoes not interleave collections with movies (real Jellyfin merges both); needs cross-source pagination, documented at the dispatch site.ListAll(nil)for collections is heavier than needed for the compat listing (counts members per request); a slim list query or short-TTL cache is a possible follow-up if collection counts grow.AI-use disclosure
Implemented by Claude Code (Fable 5) under human direction, including a multi-agent review pass whose findings were fixed in the second commit; human-validated on the dev server and Shield client.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Behavior Changes
Tests