Skip to content

fix(jellycompat): return seasons/episodes when browsing a series via /Items?ParentId= - #160

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-items-parentid-series-season
Jun 16, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-items-parentid-series-season

Conversation

@d3v1l1989

@d3v1l1989 d3v1l1989 commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Clients that browse a show through the generic /Items?ParentId= endpoint without IncludeItemTypes — e.g. the VoidTV Android-TV client's getSeasons(seriesId)/getEpisodes(seasonId), which send ParentId+SortBy=SortName and no type filter — received the top-level library views (CollectionFolders) instead of the series' seasons / the season's episodes.

HandleItems only honored an item/season ParentId when IncludeItemTypes=Season was also present; otherwise parentItemID was dropped and the request fell through to the library-views fallback (or a global type browse). On a real Jellyfin server /Items?ParentId={series} returns seasons and /Items?ParentId={season} returns episodes.

Confirmed live against a production deployment: /Items?ParentId={series} and {season} both returned the library CollectionFolders, while the dedicated /Shows/{id}/Seasons|Episodes routes worked — which is why clients using those dedicated routes were unaffected and only /Items?ParentId= browsers (VoidTV) broke.

Approach

  • Decode a season ParentId into a dedicated parentSeasonID (the codec already kind-tags item vs season ids; decoding season first keeps them distinct).
  • Route item/season parents in HandleItems:
    • season ParentId → that season's episodes
    • series ParentId → the series' seasons (default, and explicit IncludeItemTypes=Season), or the series' episodes for IncludeItemTypes=Episode; a type filter a series can't satisfy (e.g. Movie) returns an empty page rather than a wrong-typed listing.
  • Extract writeSeriesEpisodesResponse as the shared core of /Shows/{id}/Episodes and the new browse paths (avoids duplicated logic). The generic /Items browse paths honor StartIndex/Limit (matching the /Items contract and the sibling seasons listing); /Shows/{id}/Episodes keeps its existing whole-season response.

Testing

  • New parent_browse_test.go: series→seasons, season→episodes, unsatisfiable-type-filter→empty, season-parent paging, season-parent-without-repo→empty-not-views, and the parser's season/item ParentId distinction. The series/season tests use a content double that panics in ListUserLibraries, so a views-fallthrough regression fails the test rather than silently passing.
  • go test ./internal/jellycompat/..., go vet, and gofmt are clean, run in a libvips-capable container (the package needs libvips to build).

Compat

Additive: /Shows/{id}/Seasons|Episodes behavior is unchanged; movie/episode ParentIds degrade to an empty page (never a 500).

AI use

Implemented with AI assistance; the diff was reviewed in a separate pass and the tests were run in a Docker toolchain before submitting.

Summary by CodeRabbit

  • New Features
    • Added support for browsing episodes within seasons
    • Enhanced series navigation to display seasons by default, with option to view episodes directly
    • Improved pagination support for episode listings with accurate record counts and page navigation

…/Items?ParentId=

Clients that browse a show through the generic /Items?ParentId= endpoint with no
IncludeItemTypes (e.g. the VoidTV Android-TV client's getSeasons/getEpisodes) got
the top-level library views instead of the series' seasons or the season's
episodes. HandleItems only honored an item/season ParentId when
IncludeItemTypes=Season was present and otherwise fell through to the
library-views fallback (or a global type browse), so ParentId was effectively
ignored.

Decode a season ParentId into its own parentSeasonID and route item parents:
- season ParentId -> that season's episodes
- series ParentId -> the series' seasons (or its episodes for
  IncludeItemTypes=Episode; an unsatisfiable type filter returns an empty page)

Extract the shared writeSeriesEpisodesResponse used by /Shows/{id}/Episodes and
the new browse paths. The generic /Items browse paths honor StartIndex/Limit
(matching the /Items contract and the sibling seasons listing) while
/Shows/{id}/Episodes keeps its existing whole-season response.

Adds parent_browse_test.go covering series->seasons, season->episodes, the
unsatisfiable-type-filter empty case, paging, and the parser's season/item
ParentId distinction.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@d3v1l1989, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 16 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 77787a8a-470d-41b7-b9ce-d0ac4a19acb8

📥 Commits

Reviewing files that changed from the base of the PR and between 6372524 and 1f02307.

📒 Files selected for processing (2)
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/parent_browse_test.go
📝 Walkthrough

Walkthrough

ItemsHandler gains an optional *catalog.SeasonRepository dependency. itemsQuery adds a parentSeasonID field populated by parseItemsQuery when ParentId decodes as a Season. The /Items routing switch is extended to dispatch season-parent and series-parent requests to new helpers. A shared writeSeriesEpisodesResponse helper centralises episode listing with slicePage paging. Six unit tests cover all new routing and pagination paths.

Changes

Season-based parent browsing in ItemsHandler

Layer / File(s) Summary
Season ID field and ParentId decoding
internal/jellycompat/query.go
itemsQuery adds parentSeasonID string field; parseItemsQuery decodes Season-encoded ParentId values into it after checking library/collection IDs.
ItemsHandler dependency, routing, and episode-listing helpers
internal/jellycompat/handlers_items.go, internal/jellycompat/router.go
ItemsHandler gains seasonRepo field; NewItemsHandler accepts and conditionally assigns it; HandleItems switch is extended for parentSeasonID and parentItemID cases; handleItemParentChildren, handleSeasonEpisodeChildren, and itemTypesContain helpers are added; writeSeriesEpisodesResponse centralises season/episode listing with slicePage paging and StartIndex propagation; HandleEpisodes is refactored to delegate to it; router constructor call is updated.
Parent browse unit tests and parser assertion
internal/jellycompat/parent_browse_test.go
Fake season/episode repositories are introduced; six tests cover series-parent season listing, non-episode type filter empty result, season-parent episode listing, absent seasonRepo empty fallback, StartIndex/Limit pagination with total count, and parseItemsQuery season vs. series ParentId routing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main fix: enabling the /Items?ParentId= endpoint to return seasons/episodes when browsing a series, which is the core objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/jellycompat/handlers_items.go`:
- Around line 224-235: The handleSeasonEpisodeChildren function ignores the
IncludeItemTypes filter and always returns episodes when the parent is a season.
Before calling h.writeSeriesEpisodesResponse, add a check to verify that the
query.IncludeItemTypes actually includes the Episode type. If the Episode type
is not included in the filter, return emptyQueryResult(query.startIndex)
instead, just like the existing error cases in this function.
🪄 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: 431d0763-d382-4bf9-8903-0525a26df966

📥 Commits

Reviewing files that changed from the base of the PR and between 203d9be and 6372524.

📒 Files selected for processing (4)
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/parent_browse_test.go
  • internal/jellycompat/query.go
  • internal/jellycompat/router.go

Comment thread internal/jellycompat/handlers_items.go Resolved
…n ParentId

handleSeasonEpisodeChildren ignored IncludeItemTypes and always returned the
season's episodes. A season's only children are episodes, so a type filter that
excludes Episode (e.g. IncludeItemTypes=Movie) now returns an empty page,
mirroring the series-parent path's handling of unsatisfiable type filters.
Addresses a CodeRabbit review comment.
@d3v1l1989

Copy link
Copy Markdown
Contributor Author

Addressed the review comment in 1f02307: handleSeasonEpisodeChildren now returns an empty page when IncludeItemTypes is present but excludes Episode (e.g. IncludeItemTypes=Movie), short-circuiting before the season/episode lookup — symmetric with the series-parent path's handling of unsatisfiable type filters. Added TestHandleItems_SeasonParentNonEpisodeTypeIsEmpty (asserts empty + that episode listing is not reached even though episodes exist).

@Quick104
Quick104 merged commit d207e13 into Silo-Server:main Jun 16, 2026
1 check passed
Quick104 pushed a commit that referenced this pull request Jun 17, 2026
…/Items?ParentId= (#160)

* fix(jellycompat): return seasons/episodes when browsing a series via /Items?ParentId=

Clients that browse a show through the generic /Items?ParentId= endpoint with no
IncludeItemTypes (e.g. the VoidTV Android-TV client's getSeasons/getEpisodes) got
the top-level library views instead of the series' seasons or the season's
episodes. HandleItems only honored an item/season ParentId when
IncludeItemTypes=Season was present and otherwise fell through to the
library-views fallback (or a global type browse), so ParentId was effectively
ignored.

Decode a season ParentId into its own parentSeasonID and route item parents:
- season ParentId -> that season's episodes
- series ParentId -> the series' seasons (or its episodes for
  IncludeItemTypes=Episode; an unsatisfiable type filter returns an empty page)

Extract the shared writeSeriesEpisodesResponse used by /Shows/{id}/Episodes and
the new browse paths. The generic /Items browse paths honor StartIndex/Limit
(matching the /Items contract and the sibling seasons listing) while
/Shows/{id}/Episodes keeps its existing whole-season response.

Adds parent_browse_test.go covering series->seasons, season->episodes, the
unsatisfiable-type-filter empty case, paging, and the parser's season/item
ParentId distinction.

* fix(jellycompat): empty result for non-episode type filter on a season ParentId

handleSeasonEpisodeChildren ignored IncludeItemTypes and always returned the
season's episodes. A season's only children are episodes, so a type filter that
excludes Episode (e.g. IncludeItemTypes=Movie) now returns an empty page,
mirroring the series-parent path's handling of unsatisfiable type filters.
Addresses a CodeRabbit review comment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants