/
/
/
# What does this implement/fix?
An empty or whitespace-only search term was dispatched to every music
provider. Providers that reject an empty query (Apple Music, YouTube
Music) return HTTP 400, so a single empty search logged an ERROR with a
full traceback for each provider:
```
ERROR [music_assistant.music] Search on provider Apple Music failed: 400, message='Bad Request', url='https://api.music.apple.com/v1/catalog/nl/search?term=&types=artists,albums,songs,playlists&limit=8'
ERROR [music_assistant.music] Search on provider YouTube Music failed: Server returned HTTP 400: Bad Request. Request contains an invalid argument.
```
`MusicController.search` now short-circuits an empty query and returns
an empty result set. Since `@api_command("music/search")` decorates that
same method, this covers the websocket API, the MCP server tools, the
MSX bridge and all internal callers in one place instead of per
provider.
- Return empty `SearchResults` for an empty or whitespace-only search
query, before the cache lookup, the library query and the provider
fan-out.
- Add a regression test asserting no provider, library or cache call is
made for an empty query.
**Related issue (if applicable):**
- n/a
## Types of changes
<!--
Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives
the label from the ticked box and applies it automatically; the
release-notes generator uses that same label to slot this change
into the next release notes.
-->
- [x] 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
- [x] The code change is tested and works locally.
- [x] `pre-commit run --all-files` passes.
- [x] `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.
- [x] I have read and complied with the project's [AI
Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md)
for any AI-assisted contributions.
- [ ] I have [raised a PR against the documentation
repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md)
targeting the main or beta branch as appropriate.
Co-authored-by: Marvin Schenkel <[email protected]>