fix(server/m7-379): enricher leaves cover_art_source NULL when MBID missing

This commit is contained in:
2026-05-04 19:04:16 -04:00
parent 6c6c4bc1e4
commit b8f9b3891b
2 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -63,11 +63,15 @@ func (e *Enricher) EnrichAlbum(ctx context.Context, albumID pgtype.UUID) error {
}
// Step 2: MBCAA fallback. Requires fetcher + toggle on + MBID.
// When the toggle is disabled OR the album has no MBID, leave
// cover_art_source NULL so a future scan can retry once the
// scanner heals the MBID. 'none' is reserved for genuine MBCAA
// 404s where we know the album really isn't in the archive.
if !e.mbcaaOn || e.fetcher == nil {
return e.recordCover(ctx, albumID, "", "none")
return nil
}
if row.Mbid == nil || *row.Mbid == "" {
return e.recordCover(ctx, albumID, "", "none")
return nil
}
body, err := e.fetcher.Fetch(ctx, *row.Mbid)
+3 -3
View File
@@ -101,7 +101,7 @@ func TestEnrichAlbum_SidecarFound(t *testing.T) {
}
}
func TestEnrichAlbum_NoSidecarNoMBID_RecordsNone(t *testing.T) {
func TestEnrichAlbum_NoSidecarNoMBID_LeavesNull(t *testing.T) {
pool := newPool(t)
id, _ := seedAlbumWithTrack(t, pool, "NoMbid", "Artist", "")
e := NewEnricher(pool, discardLogger(), nil, true)
@@ -112,8 +112,8 @@ func TestEnrichAlbum_NoSidecarNoMBID_RecordsNone(t *testing.T) {
if err != nil {
t.Fatalf("get: %v", err)
}
if row.CoverArtSource == nil || *row.CoverArtSource != "none" {
t.Errorf("source = %v, want 'none'", row.CoverArtSource)
if row.CoverArtSource != nil {
t.Errorf("source = %v, want nil (NULL — eligible for retry on next scan)", row.CoverArtSource)
}
}