diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index f477d8aa8a..600b646023 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -2633,8 +2633,17 @@ public sealed class BaseItemRepository .GroupBy(e => e.Name!) .ToDictionary( g => g.Key, - g => g.Select(f => DeserializeBaseItem(f)).Cast().ToArray()); + g => g.Select(f => DeserializeBaseItem(f)).Where(dto => dto is not null).Cast().ToArray()); - return artistNames.Where(lookup.ContainsKey).ToDictionary(name => name, name => lookup[name]); + var result = new Dictionary(artistNames.Count); + foreach (var name in artistNames) + { + if (lookup.TryGetValue(name, out var artistArray)) + { + result[name] = artistArray; + } + } + + return result; } }