From d2c581d8e73b52522ae31f0fad27ccadfcb117ef Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sun, 12 Jul 2026 00:54:33 +0200 Subject: [PATCH] fix(discovery): use a valid ListenBrainz similar-artists algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The placeholder algorithm string (contribution_5_threshold_15_limit_50) is not a permitted enum member of the LB Labs endpoint — every lookup 400'd, making discovery inert. Verified against the live API 2026-07-12: the days_7500/contribution_3/ threshold_10/limit_100 variant returns rows shaped {artist_mbid,name,comment,score}, which the existing defensive parser already handles. Fixed in both the worker adapter and the web seed-search client (kept in sync). Co-Authored-By: Claude Opus 4.8 (1M context) --- web/src/lib/listenbrainz.ts | 5 +++-- worker/lyra_worker/similarity/_listenbrainz.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/web/src/lib/listenbrainz.ts b/web/src/lib/listenbrainz.ts index 86628af..494e06d 100644 --- a/web/src/lib/listenbrainz.ts +++ b/web/src/lib/listenbrainz.ts @@ -1,7 +1,8 @@ const LB_BASE = process.env.LISTENBRAINZ_URL ?? "https://labs.api.listenbrainz.org"; -// Keep in sync with the worker's _listenbrainz.py default algorithm. +// Keep in sync with the worker's _listenbrainz.py default algorithm. Must be a +// permitted enum member of the LB endpoint (invalid strings 400). Verified live 2026-07-12. const ALGORITHM = - "session_based_days_7500_session_300_contribution_5_threshold_15_limit_50_filter_True_skip_30"; + "session_based_days_7500_session_300_contribution_3_threshold_10_limit_100_filter_True_skip_30"; export type SimilarArtist = { mbid: string; name: string; score: number }; diff --git a/worker/lyra_worker/similarity/_listenbrainz.py b/worker/lyra_worker/similarity/_listenbrainz.py index 89a93b4..39b0886 100644 --- a/worker/lyra_worker/similarity/_listenbrainz.py +++ b/worker/lyra_worker/similarity/_listenbrainz.py @@ -3,11 +3,12 @@ import requests from lyra_worker.similarity.base import SimilarArtist _DEFAULT_URL = "https://labs.api.listenbrainz.org" -# ListenBrainz Labs similar-artists dataset requires an algorithm parameter. -# NOTE: confirm this string + response field names against the live API during -# manual verification; parsing below is defensive if the shape shifts. +# ListenBrainz Labs similar-artists dataset requires an algorithm parameter whose +# value must be one of the endpoint's permitted enum members (an invalid string 400s). +# Verified against the live API 2026-07-12: this algorithm returns rows shaped +# {artist_mbid, name, comment, score, ...}, which the parser below reads defensively. _DEFAULT_ALGORITHM = ( - "session_based_days_7500_session_300_contribution_5_threshold_15_limit_50_filter_True_skip_30" + "session_based_days_7500_session_300_contribution_3_threshold_10_limit_100_filter_True_skip_30" )