hass-music-assistant
hass-music-assistant copied to clipboard
mass.play_media fails completely when one of the (Spotify) playlists causes an error
What version of Music Assistant has the issue?
2024.1.0
The problem
I'm a calendar trigger to start this script every day : 'alias: Start muziek (week) sequence:
- service: script.set_standard_volume data: {}
- service: mass.play_media target: entity_id: media_player.hobbyruimte data: enqueue: replace media_id: - Bad girls & boys - Rockabilly Mania - 'SKÁLD: the complete playlist' - This is Bush - This is AC/DC - This is Iron Maiden - This is Moloko media_type: playlist mode: single icon: mdi:file-music'
Today the script failed to play music at all.
The timeline-trace showed this :
Entering the reported link 'spotify://playlist/37i9dQZF1DZ06evO3KIUZW' into my browser showed it was the "This is Iron Maiden" playlist that had caused an error. The music assistant log appears to have additional detail.
Starting the script again did not reproduce the error.
How to reproduce
The 'script.set_standard_volume' uses mediaplayer calls to set volume and enable shuffle.
This may not be easy to reproduce, because usually the script works perfectly.
Relevant log output
2024-02-09 06:00:16.891 ERROR (MainThread) [music_assistant.providers.spotify] playlists/37i9dQZF1DZ06evO49hLQA/tracks - {'error': {'status': 502, 'message': 'Bad gateway.'}} 2024-02-09 06:00:16.967 ERROR (MainThread) [music_assistant.providers.spotify] playlists/37i9dQZF1DZ06evO3KIUZW - {'error': {'status': 502, 'message': 'Error while loading resource'}} 2024-02-09 06:00:16.968 ERROR (MainThread) [music_assistant.webserver] [139824425099152] Error handling message: CommandMessage(message_id='fcfea6cfd2094b1a97add5e830205874', command='players/queue/play_media', args={'queue_id': 'RINCON_949F3EF61A0801400', 'media': ['library://playlist/190', 'library://playlist/187', 'spotify://playlist/5qPtR75ufTvUKTB6Nbz0Rv', 'library://playlist/142', 'library://playlist/140', 'spotify://playlist/37i9dQZF1DZ06evO3KIUZW', 'library://playlist/141'], 'option': 'replace', 'radio_mode': None}) Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/player_queues.py", line 289, in play_media media_item = await self.mass.music.get_item_by_uri(item) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/music.py", line 310, in get_item_by_uri return await self.get_item( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/music.py", line 334, in get_item return await ctrl.get( ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/media/base.py", line 188, in get details = await self.get_provider_item( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/media/base.py", line 455, in get_provider_item raise MediaNotFoundError( music_assistant.common.models.errors.MediaNotFoundError: playlist://37i9dQZF1DZ06evO3KIUZW not found on provider spotify
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/webserver.py", line 373, in _run_handler result = await result ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/music_assistant/server/controllers/player_queues.py", line 292, in play_media raise MediaNotFoundError(f"Invalid uri: {item}") from err music_assistant.common.models.errors.MediaNotFoundError: Invalid uri: spotify://playlist/37i9dQZF1DZ06evO3KIUZW
Additional information
No response
What version of Home Assistant Core are your running
2024.2.0
What type of installation are you running?
Home Assistant OS
On what type of hardware are you running?
Generic x86-64 (e.g. Intel NUC)
Seems like an upstream problem. If Spotify doesn’t return a valid result then there is not much MA can do?
I agree that MA can't do anything about 3rd parties (like Spotify) returning unexpected results. However the log makes it look like only 1 out of the 7 playlists had such issues. I was kind of hoping that at least a partial success would result in tracks getting queued instead none at all.
Possible work-around : Change the script so I'm adding only 1 playlist at a time to the queue. HA can skip the ones that cause errors which should result in a better chance of playing music.
Fair point. This will get looked at in due course.
fixed in b144
@DutchJaFO can you please confirm this has been fixed
It has been very random so I'm not 100% sure. If I don't report any new incidents in a week we can assume it is fixed.
We are tidying up so I will close this but we will reopen if you still have a problem.