fix: resolve Jellyfin collection creation failure#2511
Merged
Conversation
enoch85
added a commit
that referenced
this pull request
Mar 21, 2026
PR #2511 - fix: resolve Jellyfin collection creation failure - Remove unnecessary re-fetch after creating a Jellyfin collection - Switch getCollection to use direct getUserLibraryApi().getItem() lookup instead of query-based getItemsApi().getItems() pipeline - Construct MediaCollection from known creation response data instead of re-querying
Collaborator
Author
|
Last commit keeps the default stale-link healing in place, but avoids re-checking a collection we already reconciled earlier in the same rule run. That’s the piece that was causing Jellyfin to trip over a freshly created collection ID and restart the recreate/resync loop in #2509 |
enoch85
added a commit
that referenced
this pull request
Mar 21, 2026
PR #2511 - fix: resolve Jellyfin collection creation failure - avoid revalidating freshly reconciled collection links in the same rule run - preserve stale-link healing for normal collection add/remove paths - add focused rule executor coverage for Jellyfin resync and removal flows
Remove unnecessary re-fetch after creating a Jellyfin collection. Switch getCollection to use direct getUserLibraryApi().getItem() lookup instead of the query-based getItemsApi().getItems() pipeline. Avoid revalidating reconciled collection links within the same rule run.
f5ad63a to
6ca0b76
Compare
Contributor
|
🎉 This PR is included in version 3.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
enoch85
added a commit
that referenced
this pull request
Mar 28, 2026
…ellyfin Fixes a regression introduced in v3.2.0 where rule execution would crash with "Cannot read properties of undefined (reading 'id')" for Jellyfin users. The COLLECTION_CREATION_WITH_ITEMS optimisation (PR #2494, fixing #2489) attempted to create a Jellyfin collection with all existing item IDs in a single atomic API call. If Jellyfin rejected any ID (e.g. stale/unavailable media), the entire createCollection call threw, addToCollectionInternal returned undefined, and the caller in rule-executor then accessed collection.id on that undefined — crashing the rule run for every affected collection. The original lag problem that motivated PR #2494 was independently solved by PR #2511 (issue #2493), so the optimisation no longer provides any benefit. Fix: - Remove itemIds from all createCollection call sites; collections are always created empty and items are added via the existing addBatchToCollection path - Remove the COLLECTION_CREATION_WITH_ITEMS feature flag (enum, constants, CreateCollectionParams.itemIds) as it is now unused - Add null guards in addToCollectionWithResolvedLink and removeFromCollectionWithResolvedLink to prevent crashes if collection creation fails for any other reason - Add collection && guard in rule-executor before the remove block for the same defensive reason - Update tests to reflect the new invariant: createCollection never receives itemIds regardless of media server type Removed implementation introduced by: PR #2494 PR #2494 fixed: issue #2489 Related later Jellyfin collection creation fix: PR #2511 for issue #2493
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2493 — Jellyfin collections fail to create with
Failed to fetch created collectionerror.Root cause
How Plex does it: Plex's
POST /library/collectionsreturns the full collection object directly inresponse.MediaContainer.Metadata[0]. No re-fetch needed.How Jellyfin does it: Jellyfin's
POST /Collectionscreates the collection synchronously (persists to DB viaparentFolder.AddChild(collection)before returning), but only returns{ Id: string }. The collection exists immediately in the database when the response comes back — confirmed by the Jellyfin server source code inCollectionManager.CreateCollectionAsync.Why the re-fetch failed: The
getCollectionmethod usedgetItemsApi().getItems()— a query/search endpoint that goes through Jellyfin's item query pipeline with user-level filtering and caching. There was a known cache invalidation bug in Jellyfin 10.11.0-10.11.2 (jellyfin/jellyfin#15423), and even on later versions the query pipeline can fail to surface a just-created item.Why the re-fetch was unnecessary: Both callers of
createCollectiononly usemediaCollection.id. TheIdfrom the creation response is guaranteed valid by Jellyfin's synchronous creation.Changes
createCollection: Remove the unnecessary re-fetch. ConstructMediaCollectiondirectly from the creation responseIdand input params.getCollection: Switch fromgetItemsApi().getItems()(query pipeline) togetUserLibraryApi().getItem()(directGetItemById— hits LRU cache first, then single DB lookup, no query pipeline). This is the correct API for fetching a single item by known ID.Test plan
🤖 Generated with Claude Code