Skip to content

Conversation

@balloob
Copy link
Contributor

@balloob balloob commented Dec 24, 2025

In dev, I am currently unable to do a clean shutdown. This ends up with having items in cache where media_item=None. When these get restored, the player is unable to continue playing.

Below fix was created together with Claude. It does fix my issue but want to make sure Marcel verifies it.

The original issue was a warning, which I turned into exception to generate below log:

2025-12-24 13:20:10.943 ERROR (MainThread) [music_assistant.player_queues] Skipping unplayable item ABBA - I Have a Dream (4ce6b28a00a04f17bb5dd982710fb950)
Traceback (most recent call last):
  File "/Users/paulus/dev/mass/server/music_assistant/controllers/player_queues.py", line 922, in _play_index
    await self._load_item(
    ...<5 lines>...
    )
  File "/Users/paulus/dev/mass/server/music_assistant/controllers/player_queues.py", line 1296, in _load_item
    queue_item.streamdetails = await get_stream_details(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/Users/paulus/dev/mass/server/music_assistant/helpers/audio.py", line 252, in get_stream_details
    raise MediaNotFoundError(
        f"Unable to retrieve streamdetails for {queue_item.name} ({queue_item.uri})"
    )
music_assistant_models.errors.MediaNotFoundError: Unable to retrieve streamdetails for ABBA - I Have a Dream (4ce6b28a00a04f17bb5dd982710fb950)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a critical issue where unclean shutdowns could leave queue items with media_item=None in the cache, causing the player to fail when these items are restored. The fix implements defensive filtering during both cache restoration and cache writes.

  • Filters out queue items without media_item during cache restoration to prevent player failures
  • Prevents caching of items with null media_item at the source to avoid the issue in future
  • Improves error handling by resetting to clean state when queue restoration fails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MarvinSchenkel MarvinSchenkel merged commit e4cfbaa into dev Jan 2, 2026
18 of 20 checks passed
@MarvinSchenkel MarvinSchenkel deleted the queue-media-item branch January 2, 2026 12:07
github-actions bot pushed a commit that referenced this pull request Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants