[GH-ISSUE #659] [Issue]: Game Mode Spotify scene music fails with no active session, even when the mini-player SDK device is registered #312

Closed
opened 2026-10-20 17:27:33 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (May 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/659

Originally assigned to: @Romuromylus on GitHub.

Summary

Game Mode Spotify scene music silently fails with a generic "Spotify scene music failed." toast whenever the user has no currently-active Spotify playback session, even if the in-app Spotify Web Playback SDK has registered "Marinara Engine" as an available device. The server-side play call is sent without a device_id, so Spotify responds 404 NO_ACTIVE_DEVICE.

Expected behavior

When the user enables the Spotify mini player (which registers an SDK device named "Marinara Engine"), Game Mode scene music should be able to play to that device even if no other Spotify app is currently playing — i.e. the SDK device should be discovered and targeted automatically. If genuinely no device is available, the toast should be actionable ("enable the mini player, or open Spotify on another device") instead of a generic failure message.

Actual behavior

  1. packages/server/src/services/spotify/game-spotify-music.service.ts → playGameSpotifyTrack reads the current playback state via GET /me/player. When there's no active session, Spotify returns 204 No Content, so readPlaybackSnapshot returns null and before?.deviceId is null.
  2. The play call is built as PUT /me/player/play with no device_id query parameter.
  3. Spotify responds 404 {"error":{"status":404,"message":"Player command failed: No active device found","reason":"NO_ACTIVE_DEVICE"}}.
  4. The server throws a GameSpotifyError. The client (GameSurface.tsx) catches it and shows the generic toast "Spotify scene music failed." — the actual error message is discarded.

Steps to reproduce

  1. Connect a Spotify DJ agent (OAuth completes, scopes include streaming, user-modify-playback-state).
  2. In Settings, enable the Spotify mini player toggle so the Web Playback SDK registers "Marinara Engine" as a device.
  3. Do not start playback manually anywhere — leave the SDK device idle (is_active: false).
  4. In a Game Mode chat with Spotify music enabled and source set to Liked Songs or Any Spotify, trigger a scene that should auto-play music.
  5. Toast: Spotify scene music failed. — and GET /me/player/devices confirms "Marinara Engine" is present with is_active: false. The play call never targets it.

Environment

  • Marinara Engine version: 1.5.9 (fork main, upstream 41b7cd48)
  • Install type: docker (EasyPanel deployment, Romuromylus fork)
  • OS + version: Linode VPS (server) / Windows 11 (client)
  • Browser or app shell: Chrome (Web Playback SDK loaded from sdk.scdn.co/spotify-player.js)

Logs, screenshots, or video

Reproduced by calling Spotify Web API directly with the same access token:

GET /me/player                  -> 204 (no active session)
GET /me/player/devices          -> 200, { devices: [{ name: "Marinara Engine", is_active: false, is_restricted: false, id: "<...>" }] }
PUT /me/player/play             -> 404 NO_ACTIVE_DEVICE
PUT /me/player/play?device_id=<...>   -> 204 ✓ (music plays)

Additional context

  • Fix candidate proposed in a separate PR: when readPlaybackSnapshot returns no deviceId, fall back to GET /me/player/devices and select a target (prefer active, then "Marinara Engine" SDK device by name, then any non-restricted device). When the device list is empty, return 404 with an actionable message that the client can surface.
  • The mini-player's manual playback flow (SpotifyMiniPlayer.runControl → /spotify/player/transfer + /spotify/player/play) is not affected — it sets device_id from the SDK ready event.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (May 10, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/659 Originally assigned to: @Romuromylus on GitHub. ## Summary Game Mode Spotify scene music silently fails with a generic "Spotify scene music failed." toast whenever the user has no currently-active Spotify playback session, even if the in-app Spotify Web Playback SDK has registered "Marinara Engine" as an available device. The server-side play call is sent without a `device_id`, so Spotify responds 404 `NO_ACTIVE_DEVICE`. ## Expected behavior When the user enables the Spotify mini player (which registers an SDK device named "Marinara Engine"), Game Mode scene music should be able to play to that device even if no other Spotify app is currently playing — i.e. the SDK device should be discovered and targeted automatically. If genuinely no device is available, the toast should be actionable ("enable the mini player, or open Spotify on another device") instead of a generic failure message. ## Actual behavior 1. `packages/server/src/services/spotify/game-spotify-music.service.ts` → `playGameSpotifyTrack` reads the current playback state via `GET /me/player`. When there's no active session, Spotify returns **204 No Content**, so `readPlaybackSnapshot` returns `null` and `before?.deviceId` is `null`. 2. The play call is built as `PUT /me/player/play` with no `device_id` query parameter. 3. Spotify responds **404** `{"error":{"status":404,"message":"Player command failed: No active device found","reason":"NO_ACTIVE_DEVICE"}}`. 4. The server throws a `GameSpotifyError`. The client (`GameSurface.tsx`) catches it and shows the generic toast `"Spotify scene music failed."` — the actual error message is discarded. ## Steps to reproduce 1. Connect a Spotify DJ agent (OAuth completes, scopes include `streaming`, `user-modify-playback-state`). 2. In Settings, enable the **Spotify mini player** toggle so the Web Playback SDK registers "Marinara Engine" as a device. 3. **Do not** start playback manually anywhere — leave the SDK device idle (`is_active: false`). 4. In a Game Mode chat with Spotify music enabled and source set to **Liked Songs** or **Any Spotify**, trigger a scene that should auto-play music. 5. Toast: `Spotify scene music failed.` — and `GET /me/player/devices` confirms "Marinara Engine" is present with `is_active: false`. The play call never targets it. ## Environment - Marinara Engine version: 1.5.9 (fork main, upstream `41b7cd48`) - Install type: docker (EasyPanel deployment, Romuromylus fork) - OS + version: Linode VPS (server) / Windows 11 (client) - Browser or app shell: Chrome (Web Playback SDK loaded from `sdk.scdn.co/spotify-player.js`) ## Logs, screenshots, or video Reproduced by calling Spotify Web API directly with the same access token: ``` GET /me/player -> 204 (no active session) GET /me/player/devices -> 200, { devices: [{ name: "Marinara Engine", is_active: false, is_restricted: false, id: "<...>" }] } PUT /me/player/play -> 404 NO_ACTIVE_DEVICE PUT /me/player/play?device_id=<...> -> 204 ✓ (music plays) ``` ## Additional context - Fix candidate proposed in a separate PR: when `readPlaybackSnapshot` returns no `deviceId`, fall back to `GET /me/player/devices` and select a target (prefer active, then "Marinara Engine" SDK device by name, then any non-restricted device). When the device list is empty, return 404 with an actionable message that the client can surface. - The mini-player's manual playback flow (`SpotifyMiniPlayer.runControl` → `/spotify/player/transfer` + `/spotify/player/play`) is not affected — it sets `device_id` from the SDK `ready` event. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:33 +07:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#312
No description provided.