fix(subsonic): a scrobble of an unknown song answers not found (70) (#8125)
release / web (push) Successful in 1m20s
release / go (push) Successful in 1m49s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m3s
release / android (push) Successful in 4m26s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 4m43s

A scrobble whose id named no track reached the play writer and came back
as a generic failure (0). The handler now looks the song up first, as
stream does, and answers 70 with nothing recorded; a lookup that fails
for another reason is still a generic error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 11:56:12 -05:00
co-authored by Claude Opus 5.5
parent 4ca6c6be38
commit 1c4307e6ef
2 changed files with 34 additions and 1 deletions
+22
View File
@@ -11,6 +11,7 @@ import (
"testing"
"time"
"github.com/jackc/pgx/v5/pgtype"
"github.com/jackc/pgx/v5/pgxpool"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
@@ -125,3 +126,24 @@ func TestHandleScrobble_AWildClockIsBoundedToNow(t *testing.T) {
t.Fatalf("play dated %v, want no later than now", startedAt)
}
}
// A scrobble of a song the library doesn't hold answers "not found" (70),
// as stream and getSong do, and records nothing.
func TestHandleScrobble_AnUnknownSongIsNotFound(t *testing.T) {
pool, user, _ := testScrobblePool(t)
m := newScrobbleHandlers(pool)
unknown := uuidToID(pgtype.UUID{Bytes: [16]byte{0xee}, Valid: true})
for _, submission := range []string{"true", "false"} {
if code := call(t, m.handleScrobble, user, "id="+unknown+"&submission="+submission, nil); code != ErrDataNotFound {
t.Errorf("submission=%s: error %d, want %d", submission, code, ErrDataNotFound)
}
}
var n int
if err := pool.QueryRow(context.Background(), "SELECT count(*) FROM play_events WHERE user_id=$1", user.ID).Scan(&n); err != nil {
t.Fatal(err)
}
if n != 0 {
t.Errorf("play_events = %d, want none", n)
}
}