From b5c2878533db895880a9f1648f75bf6c9c412ea7 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:05:01 -0700 Subject: [PATCH] Fix get_artist_albums cache not actually storing data The cache stores raw_data through _extract_fields which expects a dict with a 'name' field. Storing a raw list caused silent AttributeError, and storing a dict without 'name' triggered junk entity rejection (empty string is in _JUNK_NAMES). Now wraps the albums list in a dict with a valid name field so it passes validation and persists correctly. --- core/spotify_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/spotify_client.py b/core/spotify_client.py index 0b456fe4..9a55579b 100644 --- a/core/spotify_client.py +++ b/core/spotify_client.py @@ -1318,7 +1318,8 @@ class SpotifyClient: cached = cache.get_entity(source, 'artist', cache_key) if cached: try: - return [Album.from_spotify_album(ad) for ad in cached] + albums_list = cached.get('_albums', cached) if isinstance(cached, dict) else cached + return [Album.from_spotify_album(ad) for ad in albums_list] except Exception: pass # Cache data incompatible, re-fetch @@ -1339,9 +1340,9 @@ class SpotifyClient: logger.info(f"Retrieved {len(albums)} albums for artist {artist_id}") - # Cache the full artist albums result + # Cache the full artist albums result (wrapped in dict for cache compatibility) if raw_items: - cache.store_entity('spotify', 'artist', cache_key, raw_items) + cache.store_entity('spotify', 'artist', cache_key, {'name': f'albums_{artist_id}', '_albums': raw_items}) # Also cache individual albums opportunistically entries = [(ad.get('id'), ad) for ad in raw_items if ad.get('id')] if entries: