mass_queue icon indicating copy to clipboard operation
mass_queue copied to clipboard

Get Playlist Tracks Unknown Error

Open jianyu-li opened this issue 10 months ago • 19 comments

The new Get Playlist Tracks function errors out on me.

Here is my configuration

action: mass_queue.get_playlist_tracks
data:
  config_entry_id: 02KCT759K131TC0G9GN2T55JZZ
  uri: library://playlist/547

I've also tried it with the apple music URI and it also returns an unknown error.

jianyu-li avatar Jan 09 '26 21:01 jianyu-li

Are you certain that's the correct URI? That's a lot of playlists to have.

What errors are showing up in your HA logs?

droans avatar Jan 10 '26 04:01 droans

yeah i used the copy uri function in music assistant to obtain it. image

The action just says "Failed to perform the action mass_queue.get_playlist_tracks. Unknown error"

logs say

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:524 First occurred: 8:51:08 PM (1 occurrence) Last logged: 8:51:08 PM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'NoneType' object has no attribute 'get' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 524, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1011, in _async_step_call_service response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<9 lines>... ) ^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2819, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2862, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/services.py", line 371, in get_playlist_tracks "tracks": await actions.get_playlist_tracks(uri, page), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/actions.py", line 431, in get_playlist_tracks return [self.format_playlist_track(item.to_dict()) for item in resp] ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/actions.py", line 435, in format_playlist_track result = self.format_track_item(playlist_track) File "/config/custom_components/mass_queue/actions.py", line 441, in format_track_item result = self.format_item(track_item) File "/config/custom_components/mass_queue/actions.py", line 463, in format_item media_image = find_image(media_item) or "" ~~~~~~~~~~^^^^^^^^^^^^ File "/config/custom_components/mass_queue/utils.py", line 183, in find_image from_album = find_image_from_album(data, remotely_accessible) File "/config/custom_components/mass_queue/utils.py", line 160, in find_image_from_album metadata = album.get("metadata", {}) ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

jianyu-li avatar Jan 10 '26 04:01 jianyu-li

additional logs

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/mass_queue/utils.py:160 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 8:51:08 PM (1 occurrence) Last logged: 8:51:08 PM

[139736654561824] Error handling message: Unknown error (unknown_error) from (Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Home Assistant/2026.1.1 (io.robbie.HomeAssistant; build:2026.1652; iOS 26.2.0) Mobile/HomeAssistant, like Safari) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 1050, in handle_execute_script script_result = await script_obj.async_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ msg.get("variables"), context=context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1837, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 460, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step self._handle_exception( ~~~~~~~~~~~~~~~~~~~~~~^ ex, continue_on_error, self._log_exceptions or log_exceptions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 556, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 524, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1011, in _async_step_call_service response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<9 lines>... ) ^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2819, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2862, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/services.py", line 371, in get_playlist_tracks "tracks": await actions.get_playlist_tracks(uri, page), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/actions.py", line 431, in get_playlist_tracks return [self.format_playlist_track(item.to_dict()) for item in resp] ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/config/custom_components/mass_queue/actions.py", line 435, in format_playlist_track result = self.format_track_item(playlist_track) File "/config/custom_components/mass_queue/actions.py", line 441, in format_track_item result = self.format_item(track_item) File "/config/custom_components/mass_queue/actions.py", line 463, in format_item media_image = find_image(media_item) or "" ~~~~~~~~~~^^^^^^^^^^^^ File "/config/custom_components/mass_queue/utils.py", line 183, in find_image from_album = find_image_from_album(data, remotely_accessible) File "/config/custom_components/mass_queue/utils.py", line 160, in find_image_from_album metadata = album.get("metadata", {}) ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get'

jianyu-li avatar Jan 10 '26 04:01 jianyu-li

Weird, that shouldn't error out... Let's see if the new beta fixes it.

droans avatar Jan 10 '26 14:01 droans

unfortunately the beta still results in error. all of the other new actions work though and return tracks

jianyu-li avatar Jan 11 '26 18:01 jianyu-li

Hm, I'm really not sure why. You may need to test it yourself... album should NEVER be None - if it doesn't exist or is None, it is automatically reassigned to an empty dict.

Can you try running mass_queue.send_command with the data below?

command: music/playlists/playlist_tracks
data: 
  item_id: 547
  provider_instance_id_or_domain: library
config_entry_id: 02KCT759K131TC0G9GN2T55JZZ

droans avatar Jan 12 '26 17:01 droans

unknown error again, but this time i figured out what the problem is. The item_id is expecting a string but it's being passed as an integer

this doesn't work:

action: mass_queue.send_command data: data: item_id: 547 provider_instance_id_or_domain: library config_entry_id: 01KCT648K138TD0G6GN5T44JZX command: music/playlists/playlist_tracks

but this DOES work

action: mass_queue.send_command data: data: item_id: "547" provider_instance_id_or_domain: library config_entry_id: 01KCT648K138TD0G6GN5T44JZX command: music/playlists/playlist_tracks

jianyu-li avatar Jan 12 '26 17:01 jianyu-li

Ah - that was my typo sorry, I should have made it a string.

What was the output once you corrected it?

droans avatar Jan 13 '26 22:01 droans

a ton of metadata for all the tracks on the playlist like:

response:
  - item_id: "1440948088"
    provider: apple_music
    name: Have You Ever Seen the Rain?
    version: ""
    sort_name: have you ever seen the rain?
    uri: apple_music://track/1440948088
    external_ids:
      - - isrc
        - USC4R0817643
    is_playable: true
    translation_key: null
    media_type: track
    provider_mappings:
      - item_id: "1440948088"
        provider_domain: apple_music
        provider_instance: apple_music--oJ7y23gg
        available: true
        in_library: null
        is_unique: null
        audio_format:
          content_type: aac
          codec_type: "?"
          sample_rate: 44100
          bit_depth: 16
          channels: 2
          output_format_str: aac
          bit_rate: 0
        url: >-
          https://music.apple.com/us/album/have-you-ever-seen-the-rain/1440948020?i=1440948088
        details: null
    metadata:
      description: null
      review: null
      explicit: null
      images:
        - type: thumb
          path: >-
            https://is1-ssl.mzstatic.com/image/thumb/Music115/v4/fb/93/81/fb938141-0ec9-ff80-3b57-3d3d0979e4b3/00888072356085.rgb.jpg/1500x1500bb.jpg
          provider: apple_music--oJ7y23gg
          remotely_accessible: true
      grouping: null
      genres:
        - Music
        - Rock
      mood: null
      style: null
      copyright: null
      lyrics: null
      lrc_lyrics: null
      label: null
      links: null
      performers:
        - John Fogerty
      preview: null
      popularity: null
      release_date: null
      languages: null
      chapters: null
      last_refresh: null
    favorite: false
    position: 1
    duration: 162.098
    artists:
      - item_id: "2083606"
        provider: apple_music
        name: Creedence Clearwater Revival
        version: ""
        sort_name: creedence clearwater revival
        uri: apple_music://artist/2083606
        external_ids: []
        is_playable: true
        translation_key: null
        media_type: artist
        provider_mappings:
          - item_id: "2083606"
            provider_domain: apple_music
            provider_instance: apple_music--oJ7y23gg
            available: true
            in_library: null
            is_unique: null
            audio_format:
              content_type: "?"
              codec_type: "?"
              sample_rate: 44100
              bit_depth: 16
              channels: 2
              output_format_str: "?"
              bit_rate: 0
            url: >-
              https://music.apple.com/us/artist/creedence-clearwater-revival/2083606
            details: null
        metadata:
          description: null
          review: null
          explicit: null
          images:
            - type: thumb
              path: >-
                https://is1-ssl.mzstatic.com/image/thumb/Features115/v4/bf/c5/06/bfc5064b-fd50-4305-767d-e17d8c5bb214/mza_4181412339144368008.png/3840x3840bb.jpg
              provider: apple_music--oJ7y23gg
              remotely_accessible: true
          grouping: null
          genres:
            - Rock
          mood: null
          style: null
          copyright: null
          lyrics: null
          lrc_lyrics: null
          label: null
          links: null
          performers: null
          preview: null
          popularity: null
          release_date: null
          languages: null
          chapters: null
          last_refresh: null
        favorite: false
        position: null
    last_played: 0
    album: null
    disc_number: 1
    track_number: 4

jianyu-li avatar Jan 13 '26 22:01 jianyu-li

Well, I can see that album is null but that shouldn't be an issue.

Can you try making this change to the code in utils.py and see if it works?

Around line 160:

def find_image_from_album(data: dict, remotely_accessible: bool):
    """Attempts to find the image via the album key."""
    album = data.get("album")
    if not album:
        return None
    metadata = album.get("metadata",) or {}
    img_data = metadata.get("images")
    if img_data is None:
        return None
    return search_image_list(img_data, remotely_accessible)

droans avatar Jan 13 '26 22:01 droans

error with the update and a home assistant restart

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/mass_queue/services.py:369
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 2:54:12 PM (2 occurrences)
Last logged: 2:54:17 PM

[139986506690016] Error handling message: Unknown error (unknown_error) from (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 1050, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        msg.get("variables"), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1837, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 460, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 556, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 524, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1011, in _async_step_call_service
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 624, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2819, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2862, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/mass_queue/services.py", line 369, in get_playlist_tracks
    actions = entry.runtime_data.actions
              ^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'runtime_data'

jianyu-li avatar Jan 13 '26 22:01 jianyu-li

Seems it had an issue starting up this time. Is the integration loading properly?

droans avatar Jan 13 '26 23:01 droans

dont see any errors on it

Image

jianyu-li avatar Jan 13 '26 23:01 jianyu-li

You might need to check if you used the correct config entry then - that error would occur before the other error you had.

droans avatar Jan 14 '26 03:01 droans

unknown error again, but this time i figured out what the problem is. The item_id is expecting a string but it's being passed as an integer

this doesn't work:

action: mass_queue.send_command data: data: item_id: 547 provider_instance_id_or_domain: library config_entry_id: 01KCT648K138TD0G6GN5T44JZX command: music/playlists/playlist_tracks

but this DOES work

action: mass_queue.send_command data: data: item_id: "547" provider_instance_id_or_domain: library config_entry_id: 01KCT648K138TD0G6GN5T44JZX command: music/playlists/playlist_tracks

i used the same config entry id as the one here that worked?

jianyu-li avatar Jan 14 '26 03:01 jianyu-li

Did something else change? That error is saying that Home Assistant couldn't find any entry with that ID.

droans avatar Jan 14 '26 03:01 droans

Downloaded the latest beta you released and it works!

jianyu-li avatar Jan 14 '26 16:01 jianyu-li

I just downloaded the 10.1-b.1 and it fixed the playlist failing for me.

sheyman1 avatar Jan 23 '26 21:01 sheyman1

Closed with v0.10.1

droans avatar Feb 25 '26 15:02 droans