Skip to content

fix(jellycompat): resolve smart-collection BoxSet children at read time - #161

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-smart-collection-boxset-children
Jun 16, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
d3v1l1989:fix/jellycompat-smart-collection-boxset-children

Conversation

@d3v1l1989

Copy link
Copy Markdown
Contributor

Problem

Browsing into a smart (live-query) collection via /Items?ParentId={boxsetId} returned 0 children even though the BoxSet's ChildCount showed a non-zero count (e.g. a "Directed by Quentin Tarantino" collection reporting 14 items but listing none).

handleBoxSetChildren resolved members only from the materialized library_collection_items table (ListItems). Smart collections store no rows there — their membership is a query evaluated at read time — so ListItems returned empty while ChildCount (the stored item count) stayed non-zero.

Confirmed live against a production deployment: smart "Directed by …" collections returned TotalRecordCount: 0 when browsed, while materialized collections (e.g. IMDb Top 250) returned their items correctly.

Approach

  • Branch handleBoxSetChildren on catalog.IsLiveQueryType(collection.CollectionType):
    • smart → resolve members through the query executor in smartCollectionContentIDs, mirroring the web API's loadLiveCollectionItems: Normalize → ValidateWithOptions(false,false) → ApplySmartCollectionItemLimit → library-scope intersection → access-filtered Preview (limit=1 probe, then limit=total). The resolved content IDs feed the same hydration/paging path as stored collections, preserving the smart query's order.
    • materialized → unchanged ListItems path.
  • A malformed or invalid query definition degrades to an empty page (debug-logged), never a 500 — appropriate for a browse surface.
  • Access filtering uses the session-scoped filter, so library-restricted users only see members in libraries they can access.
  • Hoist the duplicated intersectCollectionLibraryIDs helper into catalog.IntersectCollectionLibraryIDs so the web handler and the compat resolver share one implementation (the repo guidelines flag cross-file duplication).

Testing

  • New smart_boxset_test.go: smart children resolve in the query's order via an injected executor; the query's library_ids are intersected with the collection's bound libraries before the executor runs; malformed-query and no-executor cases degrade to an empty page without consulting/▶ crashing.
  • go test ./internal/jellycompat/... ./internal/catalog/..., go vet (jellycompat + catalog + api/handlers), go build ./..., and gofmt are clean, run in a libvips-capable container.

Compat

Additive. Materialized-collection browsing is unchanged; the web API's behavior is unchanged (same algorithm, now via the shared catalog helper).

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.

Browsing into a smart (live-query) collection via /Items?ParentId={boxsetId}
returned 0 children while the BoxSet's ChildCount showed a non-zero count:
handleBoxSetChildren only read materialized library_collection_items via
ListItems, which is empty for smart collections whose membership is a query
evaluated at read time. Confirmed live — smart "Directed by ..." collections
returned TotalRecordCount 0 while materialized collections returned their items.

Branch handleBoxSetChildren on catalog.IsLiveQueryType: smart collections
resolve their members through the query executor (mirroring the web API's
loadLiveCollectionItems — Normalize/Validate/ApplySmartCollectionItemLimit,
library-scope intersection, access-filtered Preview), then feed the resulting
content IDs into the same hydration path as stored collections. A malformed or
invalid query definition degrades to an empty page (never a 500).

Hoist the duplicated intersectCollectionLibraryIDs helper into
catalog.IntersectCollectionLibraryIDs so the web and compat resolvers share one
implementation.

Adds smart_boxset_test.go (smart children resolve in query order, library-scope
intersection reaches the executor, malformed-query and no-executor degrade to
empty).
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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 57 minutes and 7 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: 2362b9c2-581c-41a1-b589-9e9b6e8a50f7

📥 Commits

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

📒 Files selected for processing (6)
  • internal/api/handlers/library_collections.go
  • internal/catalog/collection_type.go
  • internal/jellycompat/handlers_collections.go
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/router.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 and usage tips.

@Quick104
Quick104 merged commit fdf8108 into Silo-Server:main Jun 16, 2026
1 check passed
Quick104 pushed a commit that referenced this pull request Jun 17, 2026
…me (#161)

Browsing into a smart (live-query) collection via /Items?ParentId={boxsetId}
returned 0 children while the BoxSet's ChildCount showed a non-zero count:
handleBoxSetChildren only read materialized library_collection_items via
ListItems, which is empty for smart collections whose membership is a query
evaluated at read time. Confirmed live — smart "Directed by ..." collections
returned TotalRecordCount 0 while materialized collections returned their items.

Branch handleBoxSetChildren on catalog.IsLiveQueryType: smart collections
resolve their members through the query executor (mirroring the web API's
loadLiveCollectionItems — Normalize/Validate/ApplySmartCollectionItemLimit,
library-scope intersection, access-filtered Preview), then feed the resulting
content IDs into the same hydration path as stored collections. A malformed or
invalid query definition degrades to an empty page (never a 500).

Hoist the duplicated intersectCollectionLibraryIDs helper into
catalog.IntersectCollectionLibraryIDs so the web and compat resolvers share one
implementation.

Adds smart_boxset_test.go (smart children resolve in query order, library-scope
intersection reaches the executor, malformed-query and no-executor degrade to
empty).
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