From 030937b196485be5c4209d1b6c215ff5a72723a6 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Wed, 4 Feb 2026 19:10:04 -0500 Subject: [PATCH] Add error handling and better logging for playlist cache deserialization --- allstarr/Controllers/AdminController.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/allstarr/Controllers/AdminController.cs b/allstarr/Controllers/AdminController.cs index d36d0bd..a4ad081 100644 --- a/allstarr/Controllers/AdminController.cs +++ b/allstarr/Controllers/AdminController.cs @@ -252,9 +252,18 @@ public class AdminController : ControllerBase // Try to use the pre-built playlist cache first (includes manual mappings!) var playlistItemsCacheKey = $"spotify:playlist:items:{config.Name}"; - var cachedPlaylistItems = await _cache.GetAsync>>(playlistItemsCacheKey); - _logger.LogDebug("Checking cache for {Playlist}: {CacheKey}, Found: {Found}, Count: {Count}", + List>? cachedPlaylistItems = null; + try + { + cachedPlaylistItems = await _cache.GetAsync>>(playlistItemsCacheKey); + } + catch (Exception cacheEx) + { + _logger.LogWarning(cacheEx, "Failed to deserialize playlist cache for {Playlist}", config.Name); + } + + _logger.LogInformation("Checking cache for {Playlist}: {CacheKey}, Found: {Found}, Count: {Count}", config.Name, playlistItemsCacheKey, cachedPlaylistItems != null, cachedPlaylistItems?.Count ?? 0); if (cachedPlaylistItems != null && cachedPlaylistItems.Count > 0)