Skip to content

Fix playlists not loading in Home Assistant - #5489

Merged
marcelveldt merged 4 commits into
devfrom
marcelveldt/music-assistant-playlist-error-b7c908
Aug 8, 2026
Merged

Fix playlists not loading in Home Assistant#5489
marcelveldt merged 4 commits into
devfrom
marcelveldt/music-assistant-playlist-error-b7c908

Conversation

@marcelveldt

@marcelveldt marcelveldt commented Aug 8, 2026

Copy link
Copy Markdown
Member

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.

  • builtin provider no longer advertises the sound effect media type on user created playlists
  • a migration corrects playlists that are already in the library, so upgrading is enough
  • added tests so it cannot be re-introduced unnoticed

Related issue (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.
  • I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.

Copilot AI lite review requested due to automatic review settings August 8, 2026 00:54
@github-actions github-actions Bot added the bugfix label Aug 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_EFFECT on user-created builtin playlists returned by BuiltinProvider.get_playlist.
  • Add a regression test ensuring user playlists’ supported_mediatypes does not include SOUND_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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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%'"

Copilot AI review requested due to automatic review settings August 8, 2026 01:17
@marcelveldt

Copy link
Copy Markdown
Member Author

Re the suppressed comment on the migration: added the json() wrapper, it costs nothing and keeps it consistent with the <= 52 step.

Worth noting the reasoning didn't quite carry over though. That note is about passing a scalar subquery into json_replace(), where the subtype decides whether the value gets embedded as JSON or as a quoted string. Here we assign straight to the column, so it's stored as text either way - checked both forms and the result is byte-identical.

Skipped the COALESCE: json_group_array over zero rows returns [], not NULL, and the column is NOT NULL so a NULL would have failed loudly rather than silently.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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')"

Comment thread music_assistant/controllers/music/migrations.py
Copilot AI review requested due to automatic review settings August 8, 2026 01:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_mediatypes existed; 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"

@marcelveldt
marcelveldt force-pushed the marcelveldt/music-assistant-playlist-error-b7c908 branch from fa1e082 to 77ee97c Compare August 8, 2026 01:44
Copilot AI review requested due to automatic review settings August 8, 2026 01:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@marcelveldt
marcelveldt marked this pull request as ready for review August 8, 2026 09:45
@marcelveldt
marcelveldt requested a lite review from Copilot August 8, 2026 09:46
@marcelveldt
marcelveldt force-pushed the marcelveldt/music-assistant-playlist-error-b7c908 branch from 77ee97c to 9b4f6d3 Compare August 8, 2026 09:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Marcel van der Veldt added 4 commits August 8, 2026 13:28
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.
@marcelveldt
marcelveldt requested a lite review from Copilot August 8, 2026 11:29
@marcelveldt
marcelveldt force-pushed the marcelveldt/music-assistant-playlist-error-b7c908 branch from 9b4f6d3 to 33aabbf Compare August 8, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@marcelveldt
marcelveldt merged commit 368bf43 into dev Aug 8, 2026
18 checks passed
@marcelveldt
marcelveldt deleted the marcelveldt/music-assistant-playlist-error-b7c908 branch August 8, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants