[PR #15768] [MERGED] Fix NullReferenceException in ApplyOrder method #14235

Closed
opened 2025-12-22 10:23:46 +01:00 by backuprepo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/15768
Author: @theguymadmax
Created: 12/11/2025
Status: Merged
Merged: 12/13/2025
Merged by: @crobibero

Base: release-10.11.zHead: fix-orderby-null-exception


📝 Commits (3)

  • 36a65b1 Fix NullReferenceException in ApplyOrder method
  • 47337c2 null check after the first ordering
  • 8f14ec6 Apply review suggestions

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 Jellyfin.Server.Implementations/Item/BaseItemRepository.cs (+3 -3)

📄 Description

Changes
Filters out ItemSortBy.Default

Issues

Log Error
Exception has occurred: CLR/System.ArgumentNullException
An exception of type 'System.ArgumentNullException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Value cannot be null.'
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at System.Linq.Queryable.ThenBy[TSource,TKey](IOrderedQueryable`1 source, Expression`1 keySelector)
   at Jellyfin.Server.Implementations.Item.BaseItemRepository.ApplyOrder(IQueryable`1 query, InternalItemsQuery filter, JellyfinDbContext context) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 1577
   at Jellyfin.Server.Implementations.Item.BaseItemRepository.ApplyGroupingFilter(JellyfinDbContext context, IQueryable`1 dbQuery, InternalItemsQuery filter) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 406
   at Jellyfin.Server.Implementations.Item.BaseItemRepository.GetItemList(InternalItemsQuery filter) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 296
   at Emby.Server.Implementations.Library.LibraryManager.GetItemList(InternalItemsQuery query, Boolean allowExternalContent) in C:\Gits\jellyfin\Emby.Server.Implementations\Library\LibraryManager.cs:line 1424
   at Emby.Server.Implementations.Library.LibraryManager.GetItemList(InternalItemsQuery query) in C:\Gits\jellyfin\Emby.Server.Implementations\Library\LibraryManager.cs:line 1436
   at MediaBrowser.Controller.Entities.Folder.QueryWithPostFiltering2(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 758
   at MediaBrowser.Controller.Entities.Folder.QueryRecursive(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 744
   at MediaBrowser.Controller.Entities.UserRootFolder.GetItemsInternal(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\UserRootFolder.cs:line 74
   at MediaBrowser.Controller.Entities.Folder.GetItems(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 929
   at Jellyfin.Api.Controllers.ItemsController.GetItems(Nullable`1 userId, String maxOfficialRating, Nullable`1 hasThemeSong, Nullable`1 hasThemeVideo, Nullable`1 hasSubtitles, Nullable`1 hasSpecialFeature, Nullable`1 hasTrailer, Nullable`1 adjacentTo, Nullable`1 indexNumber, Nullable`1 parentIndexNumber, Nullable`1 hasParentalRating, Nullable`1 isHd, Nullable`1 is4K, LocationType[] locationTypes, LocationType[] excludeLocationTypes, Nullable`1 isMissing, Nullable`1 isUnaired, Nullable`1 minCommunityRating, Nullable`1 minCriticRating, Nullable`1 minPremiereDate, Nullable`1 minDateLastSaved, Nullable`1 minDateLastSavedForUser, Nullable`1 maxPremiereDate, Nullable`1 hasOverview, Nullable`1 hasImdbId, Nullable`1 hasTmdbId, Nullable`1 hasTvdbId, Nullable`1 isMovie, Nullable`1 isSeries, Nullable`1 isNews, Nullable`1 isKids, Nullable`1 isSports, Guid[] excludeItemIds, Nullable`1 startIndex, Nullable`1 limit, Nullable`1 recursive, String searchTerm, SortOrder[] sortOrder, Nullable`1 parentId, ItemFields[] fields, BaseItemKind[] excludeItemTypes, BaseItemKind[] includeItemTypes, ItemFilter[] filters, Nullable`1 isFavorite, MediaType[] mediaTypes, ImageType[] imageTypes, ItemSortBy[] sortBy, Nullable`1 isPlayed, String[] genres, String[] officialRatings, String[] tags, Int32[] years, Nullable`1 enableUserData, Nullable`1 imageTypeLimit, ImageType[] enableImageTypes, String person, Guid[] personIds, String[] personTypes, String[] studios, String[] artists, Guid[] excludeArtistIds, Guid[] artistIds, Guid[] albumArtistIds, Guid[] contributingArtistIds, String[] albums, Guid[] albumIds, Guid[] ids, VideoType[] videoTypes, String minOfficialRating, Nullable`1 isLocked, Nullable`1 isPlaceHolder, Nullable`1 hasOfficialRating, Nullable`1 collapseBoxSetItems, Nullable`1 minWidth, Nullable`1 minHeight, Nullable`1 maxWidth, Nullable`1 maxHeight, Nullable`1 is3D, SeriesStatus[] seriesStatus, String nameStartsWithOrGreater, String nameStartsWith, String nameLessThan, Guid[] studioIds, Guid[] genreIds, Boolean enableTotalRecordCount, Nullable`1 enableImages) in C:\Gits\jellyfin\Jellyfin.Api\Controllers\ItemsController.cs:line 523
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/15768 **Author:** [@theguymadmax](https://github.com/theguymadmax) **Created:** 12/11/2025 **Status:** ✅ Merged **Merged:** 12/13/2025 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `release-10.11.z` ← **Head:** `fix-orderby-null-exception` --- ### 📝 Commits (3) - [`36a65b1`](https://github.com/jellyfin/jellyfin/commit/36a65b1b043f6c9ff935e5d422f310dd8aba62a1) Fix NullReferenceException in ApplyOrder method - [`47337c2`](https://github.com/jellyfin/jellyfin/commit/47337c2b15bbd43c0390bff31387d2efb9d1eaf5) null check after the first ordering - [`8f14ec6`](https://github.com/jellyfin/jellyfin/commit/8f14ec69da999facec26d7faaa3f5c0c27e609c4) Apply review suggestions ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `Jellyfin.Server.Implementations/Item/BaseItemRepository.cs` (+3 -3) </details> ### 📄 Description <!-- Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y). For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our documentation. --> **Changes** Filters out `ItemSortBy.Default` **Issues** <details> <summary>Log Error</summary> ``` Exception has occurred: CLR/System.ArgumentNullException An exception of type 'System.ArgumentNullException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Value cannot be null.' at System.ArgumentNullException.Throw(String paramName) at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName) at System.Linq.Queryable.ThenBy[TSource,TKey](IOrderedQueryable`1 source, Expression`1 keySelector) at Jellyfin.Server.Implementations.Item.BaseItemRepository.ApplyOrder(IQueryable`1 query, InternalItemsQuery filter, JellyfinDbContext context) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 1577 at Jellyfin.Server.Implementations.Item.BaseItemRepository.ApplyGroupingFilter(JellyfinDbContext context, IQueryable`1 dbQuery, InternalItemsQuery filter) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 406 at Jellyfin.Server.Implementations.Item.BaseItemRepository.GetItemList(InternalItemsQuery filter) in C:\Gits\jellyfin\Jellyfin.Server.Implementations\Item\BaseItemRepository.cs:line 296 at Emby.Server.Implementations.Library.LibraryManager.GetItemList(InternalItemsQuery query, Boolean allowExternalContent) in C:\Gits\jellyfin\Emby.Server.Implementations\Library\LibraryManager.cs:line 1424 at Emby.Server.Implementations.Library.LibraryManager.GetItemList(InternalItemsQuery query) in C:\Gits\jellyfin\Emby.Server.Implementations\Library\LibraryManager.cs:line 1436 at MediaBrowser.Controller.Entities.Folder.QueryWithPostFiltering2(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 758 at MediaBrowser.Controller.Entities.Folder.QueryRecursive(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 744 at MediaBrowser.Controller.Entities.UserRootFolder.GetItemsInternal(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\UserRootFolder.cs:line 74 at MediaBrowser.Controller.Entities.Folder.GetItems(InternalItemsQuery query) in C:\Gits\jellyfin\MediaBrowser.Controller\Entities\Folder.cs:line 929 at Jellyfin.Api.Controllers.ItemsController.GetItems(Nullable`1 userId, String maxOfficialRating, Nullable`1 hasThemeSong, Nullable`1 hasThemeVideo, Nullable`1 hasSubtitles, Nullable`1 hasSpecialFeature, Nullable`1 hasTrailer, Nullable`1 adjacentTo, Nullable`1 indexNumber, Nullable`1 parentIndexNumber, Nullable`1 hasParentalRating, Nullable`1 isHd, Nullable`1 is4K, LocationType[] locationTypes, LocationType[] excludeLocationTypes, Nullable`1 isMissing, Nullable`1 isUnaired, Nullable`1 minCommunityRating, Nullable`1 minCriticRating, Nullable`1 minPremiereDate, Nullable`1 minDateLastSaved, Nullable`1 minDateLastSavedForUser, Nullable`1 maxPremiereDate, Nullable`1 hasOverview, Nullable`1 hasImdbId, Nullable`1 hasTmdbId, Nullable`1 hasTvdbId, Nullable`1 isMovie, Nullable`1 isSeries, Nullable`1 isNews, Nullable`1 isKids, Nullable`1 isSports, Guid[] excludeItemIds, Nullable`1 startIndex, Nullable`1 limit, Nullable`1 recursive, String searchTerm, SortOrder[] sortOrder, Nullable`1 parentId, ItemFields[] fields, BaseItemKind[] excludeItemTypes, BaseItemKind[] includeItemTypes, ItemFilter[] filters, Nullable`1 isFavorite, MediaType[] mediaTypes, ImageType[] imageTypes, ItemSortBy[] sortBy, Nullable`1 isPlayed, String[] genres, String[] officialRatings, String[] tags, Int32[] years, Nullable`1 enableUserData, Nullable`1 imageTypeLimit, ImageType[] enableImageTypes, String person, Guid[] personIds, String[] personTypes, String[] studios, String[] artists, Guid[] excludeArtistIds, Guid[] artistIds, Guid[] albumArtistIds, Guid[] contributingArtistIds, String[] albums, Guid[] albumIds, Guid[] ids, VideoType[] videoTypes, String minOfficialRating, Nullable`1 isLocked, Nullable`1 isPlaceHolder, Nullable`1 hasOfficialRating, Nullable`1 collapseBoxSetItems, Nullable`1 minWidth, Nullable`1 minHeight, Nullable`1 maxWidth, Nullable`1 maxHeight, Nullable`1 is3D, SeriesStatus[] seriesStatus, String nameStartsWithOrGreater, String nameStartsWith, String nameLessThan, Guid[] studioIds, Guid[] genreIds, Boolean enableTotalRecordCount, Nullable`1 enableImages) in C:\Gits\jellyfin\Jellyfin.Api\Controllers\ItemsController.cs:line 523 at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() ``` </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
backuprepo 2025-12-22 10:23:47 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#14235
No description provided.