From f72d193ef71b7ad5d3b821c8ebc2b477dd27fc92 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 15 Jul 2026 00:50:35 +0200 Subject: [PATCH] chore(discover): raise_for_status on Last.fm fetches A 4xx/5xx (rate limit / auth) now raises instead of parsing an error body; callers already handle it (discovery per-source try/except; album fetch returns []). Closes the last small deferred cleanup. Co-Authored-By: Claude Opus 4.8 (1M context) --- worker/lyra_worker/similarity/_lastfm.py | 1 + worker/lyra_worker/similarity/_lastfm_albums.py | 1 + 2 files changed, 2 insertions(+) diff --git a/worker/lyra_worker/similarity/_lastfm.py b/worker/lyra_worker/similarity/_lastfm.py index 9001aee..c314903 100644 --- a/worker/lyra_worker/similarity/_lastfm.py +++ b/worker/lyra_worker/similarity/_lastfm.py @@ -31,6 +31,7 @@ class LastfmSource: params={"method": method, "api_key": self._key, "format": "json", **params}, timeout=self._timeout, ) + res.raise_for_status() # a 4xx/5xx (rate limit, auth) → RequestException, handled by callers return res.json() def health(self) -> bool: diff --git a/worker/lyra_worker/similarity/_lastfm_albums.py b/worker/lyra_worker/similarity/_lastfm_albums.py index af1515e..7d4c27f 100644 --- a/worker/lyra_worker/similarity/_lastfm_albums.py +++ b/worker/lyra_worker/similarity/_lastfm_albums.py @@ -41,6 +41,7 @@ class LastfmAlbumPopularity: "api_key": self._key, "format": "json", "limit": str(self._limit), "autocorrect": "1", }, timeout=self._timeout) + res.raise_for_status() return _parse_top_albums(res.json()) except Exception: # a Last.fm outage must never abort the sweep return []