Fix playlists not loading in Home Assistant - #5489
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Home Assistant playlist browsing/playback failures caused by builtin user playlists advertising an unsupported SOUND_EFFECT media type, which older HA clients reject (aborting the entire playlist listing).
Changes:
- Stop advertising
MediaType.SOUND_EFFECTon user-created builtin playlists returned byBuiltinProvider.get_playlist. - Add a regression test ensuring user playlists’
supported_mediatypesdoes not includeSOUND_EFFECT.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
music_assistant/providers/builtin/__init__.py |
Removes MediaType.SOUND_EFFECT from supported_mediatypes for user-created playlists (M3U-backed) to maintain compatibility with older Home Assistant clients. |
tests/providers/builtin/test_playlist_media_types.py |
Adds a focused async test that asserts user playlists do not advertise SOUND_EFFECT. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
music_assistant/controllers/music/migrations.py:977
- [PROBLEM] This migration rebuilds a JSON array via a scalar subquery but does not wrap it in json(...); earlier in this file you note that without json() the rebuilt array can be stored as an escaped string on some SQLite versions (see the <=52 step). Wrapping the subquery result (and COALESCE’ing an empty result) makes the stored playlists column robust across SQLite versions and edge cases.
f"UPDATE {DB_TABLE_PLAYLISTS} SET supported_mediatypes = ("
"SELECT json_group_array(value) FROM json_each"
f"({DB_TABLE_PLAYLISTS}.supported_mediatypes) WHERE value != 'sound_effect')"
" WHERE json_valid(supported_mediatypes)"
" AND supported_mediatypes LIKE '%sound_effect%'"
|
Re the suppressed comment on the migration: added the Worth noting the reasoning didn't quite carry over though. That note is about passing a scalar subquery into Skipped the COALESCE: |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
tests/controllers/music/test_music_migrations.py:474
- [PROBLEM] The migration test doesn’t cover the edge case where supported_mediatypes contains only "sound_effect"; this case currently risks breaking the migration due to NOT NULL constraints and should be asserted to prevent regressions.
await database.execute(
"INSERT INTO playlists (item_id, supported_mediatypes) VALUES "
'(1, \'["track","sound_effect","radio"]\'), '
"(2, '[\"track\"]'), "
"(3, 'corrupt value naming sound_effect')"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
tests/controllers/music/test_music_migrations.py:56
- [PROBLEM] The comment says "every playlists table at the schema versions under test carries this column", but this fixture is used for migration tests that cover schema versions before
supported_mediatypesexisted; the fixture is intentionally a minimal stand-in, so this wording is misleading for future maintainers.
"[external_ids] json NOT NULL DEFAULT '[]'"
# every playlists table at the schema versions under test carries this column
+ (
", [supported_mediatypes] json NOT NULL DEFAULT '[\"track\"]'"
if table == "playlists"
fa1e082 to
77ee97c
Compare
77ee97c to
9b4f6d3
Compare
The builtin provider advertised the sound effect media type on user created playlists. Clients that do not know this media type yet refuse to parse the playlist listing at all, which breaks playing and browsing playlists from Home Assistant.
Home Assistant reads the library copy of a playlist, so the stale media type stays in the database until the next library sync. Rewrite the affected rows in a migration so upgrading is enough.
9b4f6d3 to
33aabbf
Compare
What does this implement/fix?
Playing or browsing a Music Assistant playlist from Home Assistant fails with
Playlists are only supported for {...}, and because one bad playlist aborts the whole listing, all playlists become unusable from Home Assistant.The builtin provider recently started advertising the "sound effect" media type on user created playlists. Home Assistant ships an older client that does not know this media type yet and refuses to parse a playlist that uses it.
Sound effects can still be added to these playlists — the builtin provider accepts any item regardless of this (advisory) list. We can advertise it again once Home Assistant ships a client that understands it.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.