Skip to content

fix: skip metadata source search when query and filters are empty - #6873

Open
Sanjays2402 wants to merge 5 commits into
beetbox:masterfrom
Sanjays2402:fix/skip-empty-metadata-search
Open

fix: skip metadata source search when query and filters are empty#6873
Sanjays2402 wants to merge 5 commits into
beetbox:masterfrom
Sanjays2402:fix/skip-empty-metadata-search

Conversation

@Sanjays2402

Copy link
Copy Markdown

Description

Fixes #6862.

Items with no artist/title tags produce a search with an empty query and no filters. The request was still sent to the metadata source API, and MusicBrainz answers it with 400 Bad Request, logging a traceback once per affected file. _search_api now returns no candidates instead of issuing a request that cannot match anything.

To Do

  • Documentation (bugfix, no user-facing option changed)
  • Changelog.
  • Tests. (test_search_api_skips_request_without_query_and_filters fails without the fix, passes with it.)

Copilot AI review requested due to automatic review settings July 25, 2026 00:42
@Sanjays2402
Sanjays2402 requested review from a team and semohr as code owners July 25, 2026 00:42

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

grug see PR fix metadata source search path. When query empty and filters empty, PR now skip API call so no more MusicBrainz 400 spam for junk files with no tags.

Changes:

  • Add guard in SearchApiMetadataSourcePlugin._search_api to return no candidates when query+filters both empty.
  • Add regression test to ensure empty search does not call provider and does not raise even when raise_on_error true.
  • Add changelog entry for bug 🐛6862.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
beets/metadata_plugins.py Skip doomed API request when both query and filters are empty; return empty result set.
test/test_metadata_plugins.py Add regression test covering empty query+filters behavior.
docs/changelog.rst Document the bugfix in the changelog.

Comment thread docs/changelog.rst Outdated
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.74%. Comparing base (dc1709e) to head (54b5d41).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6873   +/-   ##
=======================================
  Coverage   75.74%   75.74%           
=======================================
  Files         164      164           
  Lines       21437    21440    +3     
  Branches     3379     3380    +1     
=======================================
+ Hits        16237    16240    +3     
  Misses       4400     4400           
  Partials      800      800           
Files with missing lines Coverage Δ
beets/metadata_plugins.py 85.02% <100.00%> (+0.27%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread docs/changelog.rst Outdated
Comment thread beets/metadata_plugins.py Outdated
Comment thread docs/changelog.rst Outdated

@semohr semohr 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.

Thanks! Please rebase onto master and fix the failing CI and we can merge this 👍

Items with no artist or title tags produce a search with an empty query
and no filters. The request was still sent to the metadata source API,
and MusicBrainz answers it with a 400 Bad Request, which was logged with
a traceback once per affected file during an import.

Return no candidates instead of issuing a request that cannot match
anything.
@Sanjays2402
Sanjays2402 force-pushed the fix/skip-empty-metadata-search branch from 6ec0eb0 to 4596bd2 Compare August 6, 2026 17:06
@Sanjays2402

Copy link
Copy Markdown
Author

Rebased onto master (was 56 commits behind) and fixed the docs job. The only red check was Check docs, and the failure was docs/changelog.rst could be reformatted from poe format-docs --check — my entry's line wrapping didn't match docstrfmt after the reword. Reflowed it with docstrfmt 2.2.0, no wording change. Rebase was conflict-free and the diff against master is unchanged at 16 insertions across the three files. test/test_metadata_plugins.py is 16 passed locally.

@semohr

semohr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

400 Bad Request when artist/title tags are empty

3 participants