[PR #8189] Fix GetItems IndexOutOfRangeException when IDs do not exist #11643

Closed
opened 2026-02-07 06:42:02 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/jellyfin/jellyfin/pull/8189

State: closed
Merged: Yes


Changes
Resolve a System.IndexOutOfRangeException when requesting IDs that do not exist via /Users/.../Items. Previously it was possible for the 'index' values in 'positions' to refer beyond 'size'. It seems the code previously assumed that all requested items exist

[ERR] Error processing request. URL "GET" "/Users/.../Items".
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at MediaBrowser.Controller.Entities.Folder.SortItemsByRequest(InternalItemsQuery query, IReadOnlyList`1 items)
   at MediaBrowser.Controller.Entities.Folder.GetItems(InternalItemsQuery query)
   at Jellyfin.Api.Controllers.ItemsController.GetItems

It caused jellyfin-kodi automatic syncs (i.e. the sync that happens automatically while Kodi is running) to fail as per #3531. I could get a consistent repro by making the same request via curl. With this change, Kodi is automatically syncing again, and the curl request returns correct results.

Issues
Fixes #3531

**Original Pull Request:** https://github.com/jellyfin/jellyfin/pull/8189 **State:** closed **Merged:** Yes --- **Changes** Resolve a System.IndexOutOfRangeException when requesting IDs that do not exist via /Users/.../Items. Previously it was possible for the 'index' values in 'positions' to refer beyond 'size'. It seems the code previously assumed that all requested items exist ``` [ERR] Error processing request. URL "GET" "/Users/.../Items". System.IndexOutOfRangeException: Index was outside the bounds of the array. at MediaBrowser.Controller.Entities.Folder.SortItemsByRequest(InternalItemsQuery query, IReadOnlyList`1 items) at MediaBrowser.Controller.Entities.Folder.GetItems(InternalItemsQuery query) at Jellyfin.Api.Controllers.ItemsController.GetItems ``` It caused jellyfin-kodi automatic syncs (i.e. the sync that happens automatically while Kodi is running) to fail as per #3531. I could get a consistent repro by making the same request via curl. With this change, Kodi is automatically syncing again, and the curl request returns correct results. **Issues** Fixes #3531
OVERLORD added the pull-request label 2026-02-07 06:42:02 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#11643