Skip to content

feat(catalog): remove smart collection item limit cap - #340

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
RXWatcher:raise-smart-collection-limit
Jul 9, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
RXWatcher:raise-smart-collection-limit

Conversation

@RXWatcher

@RXWatcher RXWatcher commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

MaxSmartCollectionItemLimit silently clamps every smart collection's query definition to 500 items (ApplySmartCollectionItemLimit), and an unset limit defaults to 100. On servers with large libraries this truncates collections with no indication to the admin — a per-language smart collection (original_language is fr) on our server has 10,625 real matches, so it showed under 1% of them, cut off mid-alphabet.

Change

Remove the cap entirely, and make an unset limit resolve the full result set (the default becomes a large sentinel so every consumer's int plumbing / SQL LIMIT keeps working). An explicit positive limit in the query definition is still honored as-is: membership size is an admin decision, and every read path that serves collection items either paginates in SQL or scales with the actual collection size rather than this value.

Validation

Running on prod (2026-07-08) via a hotfix image with all 50 language collections unstamped — they resolve their full membership. go build / go vet / go test ./internal/catalog/ pass. Rebased onto current main.

Companion PR from the same incident: #347 (Meilisearch task-wait timeout).

AI-use disclosure

Updated with Claude Code (Claude Fable 5); prod-validated.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@RXWatcher, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 85bc567b-8f35-40d7-99b6-51cb9c57b8f3

📥 Commits

Reviewing files that changed from the base of the PR and between 7ab55cb and c65ff37.

📒 Files selected for processing (3)
  • internal/catalog/query_definition.go
  • internal/jellycompat/handlers_collections.go
  • internal/jellycompat/smart_boxset_test.go
✨ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8dcf6ce72

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/catalog/query_definition.go Outdated
const (
DefaultSmartCollectionItemLimit = 100
MaxSmartCollectionItemLimit = 500
MaxSmartCollectionItemLimit = 50000

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound unpaginated smart collection expansion

When a smart collection is configured with a limit above the old 500 cap, this new cap also applies to unpaginated expansion paths: I checked HandleGetLibraryCollectionItems → loadLiveCollectionItems in internal/api/handlers/library_collections.go, which counts the live query and then reruns Preview(..., total) before returning one browseResponse with every item. A 10k–50k member collection is still paged in the catalog browse path, but this endpoint now materializes and serializes tens of thousands of rows per request instead of at most 500, which can create latency/memory spikes when admins or clients fetch collection items directly. Please keep the membership cap separate from unpaginated response caps or add pagination/bounding on these expansion paths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — we audited both first-party clients for exactly this:

  • silo-apple (iOS/tvOS) already resolves library collection items through the paginated catalog endpoint (/api/v1/catalog?source=library_collection with offset/limit), so it was never exposed to unbounded expansion here.
  • silo-android (mobile + TV) was affected: its collection detail screens called GET /api/v1/library/{id}/collections/{collection_id}/items with no pagination. The Android app has been updated to match the Apple client and use the paginated catalog endpoint instead.

With that, no first-party client depends on full unpaginated expansion from this endpoint anymore, and bounding it (or adding limit/offset params) can land as a follow-up without breaking clients. We kept it out of this PR to keep the change minimal.

@RXWatcher
RXWatcher force-pushed the raise-smart-collection-limit branch from f8dcf6c to b1b792d Compare July 8, 2026 12:57
@RXWatcher RXWatcher changed the title feat(catalog): raise MaxSmartCollectionItemLimit from 500 to 50,000 feat(catalog): remove smart collection item limit cap Jul 8, 2026
MaxSmartCollectionItemLimit silently clamped every smart collection to
500 items, and an unset limit defaulted to 100. On servers with large
libraries this truncates collections with no indication to the admin —
a per-language smart collection (original_language is fr) has 10,625
real matches and showed under 1% of them.

Remove the cap and make an unset limit resolve the full result set: the
default becomes a large sentinel so every consumer's int plumbing (SQL
LIMIT) keeps working. An explicit positive limit in the query
definition is still honored as-is — membership size is an admin
decision, and every read path that serves collection items either
paginates in SQL or scales with the actual collection size.

Co-Authored-By: Claude Fable 5 <[email protected]>
@RXWatcher

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

The Jellyfin BoxSet children path resolved a smart (live-query) collection's
entire membership and sliced one page locally. With the item cap removed
(smart collection membership is now uncapped, an admin decision), a large
collection browsed from a Jellyfin client materialized tens of thousands of
rows per request — latency and memory scaling with collection size.

For the default browse (no explicit SortBy), page the smart query directly in
SQL via QueryExecutor.PreviewPage(offset, limit), hydrating only the requested
page. Per-request work is now proportional to page size, not collection size.
TotalRecordCount still reports true membership (the count query caps at the
query's item limit), and past-the-end pages preserve the real total.

Shared query prep is extracted into prepareSmartCollectionQuery, used by both
the new paged path and the existing full-resolution path (still used by the
explicit-sort allowlist branch, whose output is already SQL-paginated).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Quick104
Quick104 merged commit ec5fb20 into Silo-Server:main Jul 9, 2026
1 check passed
Quick104 pushed a commit that referenced this pull request Jul 10, 2026
* feat(catalog): remove smart collection item limit cap

MaxSmartCollectionItemLimit silently clamped every smart collection to
500 items, and an unset limit defaulted to 100. On servers with large
libraries this truncates collections with no indication to the admin —
a per-language smart collection (original_language is fr) has 10,625
real matches and showed under 1% of them.

Remove the cap and make an unset limit resolve the full result set: the
default becomes a large sentinel so every consumer's int plumbing (SQL
LIMIT) keeps working. An explicit positive limit in the query
definition is still honored as-is — membership size is an admin
decision, and every read path that serves collection items either
paginates in SQL or scales with the actual collection size.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(jellycompat): page smart collection browse in SQL

The Jellyfin BoxSet children path resolved a smart (live-query) collection's
entire membership and sliced one page locally. With the item cap removed
(smart collection membership is now uncapped, an admin decision), a large
collection browsed from a Jellyfin client materialized tens of thousands of
rows per request — latency and memory scaling with collection size.

For the default browse (no explicit SortBy), page the smart query directly in
SQL via QueryExecutor.PreviewPage(offset, limit), hydrating only the requested
page. Per-request work is now proportional to page size, not collection size.
TotalRecordCount still reports true membership (the count query caps at the
query's item limit), and past-the-end pages preserve the real total.

Shared query prep is extracted into prepareSmartCollectionQuery, used by both
the new paged path and the existing full-resolution path (still used by the
explicit-sort allowlist branch, whose output is already SQL-paginated).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: rxwatcher <[email protected]>
bulderi pushed a commit to bulderi/silo-server that referenced this pull request Oct 5, 2026
The web editors rewrote saved smart collections without saying so. They
defaulted the item limit to 100 and capped it at 500, although the server
has left smart collections uncapped since Silo-Server#340 and stores a 10,000,000
sentinel for "no limit", so saving any uncapped collection cut it to 500.
The Guided view rebuilds the definition from its own form state, so a
toolbar sort or media change, or any Guided edit, dropped the rules it
cannot show: negated rules, OR groups, repeated actor or director rules.

A blank Max items field now means no limit and is left out on save, and
an explicit limit passes through unchanged. A definition that Guided
cannot reproduce opens in Advanced with Guided switched off and a short
note, the toolbar changes only the sort and media scope, and the Filters
count includes every rule. The wizard lets a collection with no matches
continue to Details, and the Advanced Media Scope lists Movies & Series
and Manga. Collections that earlier saves already truncated stay
truncated.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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