Skip to content

fix(tidal): honour search_limit in album and track query searches - #7197

Closed
thanvish21 wants to merge 1 commit into
beetbox:masterfrom
thanvish21:fix/tidal-search-limit
Closed

thanvish21 wants to merge 1 commit into
beetbox:masterfrom
thanvish21:fix/tidal-search-limit

Conversation

@thanvish21

Copy link
Copy Markdown

Problem

Closes #6770.

The tidal plugin's search_albums_by_query and search_tracks_by_query called api.search_results() without respecting the search_limit configured by MetadataSourcePlugin. This caused Tidal to return 20+ candidates even when the user set e.g.:

tidal:
  search_limit: 1

Root cause

Both query-search methods returned the full relationship list from the search document to the ID-resolution step. The shared search_limit path in MetadataSourcePlugin.search() was never reached because candidates() and item_candidates() call these methods directly.

Fix

Read self.config["search_limit"].get(int) in both methods and slice the relationship list before passing IDs to search_albums_by_ids / iterating tracks:

# search_albums_by_query
limit = self.config["search_limit"].get(int)
album_ids = [
    album_rel["id"]
    for album_rel in search_doc["data"][0]["relationships"]["albums"]["data"][:limit]
]

# search_tracks_by_query
limit = self.config["search_limit"].get(int)
for track_rel in search_doc["data"][0]["relationships"]["tracks"]["data"][:limit]:
    ...

Tests

Two new focused tests added in test/plugins/test_tidal.py:

  • TestCandidates::test_search_albums_respects_search_limit — verifies only search_limit album IDs are requested when the API returns more
  • TestItemCandidates::test_search_tracks_respects_search_limit — verifies only search_limit tracks are returned from a multi-track search response

All 62 tidal tests pass (uv run pytest test/plugins/test_tidal.py).

🤖 Generated with Claude Code

The tidal plugin's search_albums_by_query and search_tracks_by_query
called api.search_results() without respecting the search_limit
configured by the MetadataSourcePlugin base class. This caused Tidal to
return 20+ candidates even when the user set e.g. `tidal:
search_limit: 1`.

Fix: read self.config["search_limit"].get(int) in both methods and
slice the relationship list before resolving album/track IDs.

Add focused tests for both album and track search with search_limit: 1
to guard against regressions.

Closes: beetbox#6770

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thanvish21
thanvish21 requested review from a team and semohr as code owners November 19, 2026 12:44
Copilot AI balanced review requested due to automatic review settings November 19, 2026 12: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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.85%. Comparing base (cf0983a) to head (b4d0004).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7197      +/-   ##
==========================================
- Coverage   80.86%   80.85%   -0.01%     
==========================================
  Files         150      150              
  Lines       21232    21234       +2     
  Branches     3241     3241              
==========================================
  Hits        17169    17169              
- Misses       3248     3250       +2     
  Partials      815      815              
Files with missing lines Coverage Δ
beetsplug/tidal/__init__.py 90.19% <100.00%> (+0.07%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@semohr

semohr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Please see the other PRs and the discussion around this issue. IDs are not returned by any priority order therefore the fix here would not work.

@semohr semohr closed this Nov 19, 2026
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.

tidal: search_limit is ignored

3 participants