Skip to content

Log failed metadata searches without a traceback at error level - #7119

Merged
snejus merged 3 commits into
beetbox:masterfrom
wolfgang-aura:mailman/issue-6960
Nov 1, 2026
Merged

snejus merged 3 commits into
beetbox:masterfrom
wolfgang-aura:mailman/issue-6960

Conversation

@wolfgang-aura

Copy link
Copy Markdown
Contributor

Description

Fixes #6960.

When MusicBrainz is down or unreachable, beet import prints a 50-line urllib3/requests traceback for every search. _search_api in beets/metadata_plugins.py catches the error but logs it at error level with exc_info=True.

Search failures caused by requests (ConnectionError, Timeout, retries exhausted, HTTP errors) now log the one-line message at error level, for example Error searching MusicBrainz: HTTPSConnectionPool(host='musicbrainz.org', port=443): Max retries exceeded ..., and keep the traceback at debug level. That is how maybe_handle_plugin_error in the same module already logs plugin failures. raise_on_error still re-raises, and errors that are not from requests keep the full traceback, since those are more likely bugs.

The thread suggested catching connection errors in RequestHandler instead. I kept the change in _search_api because every search-based metadata source goes through it, including plugins that do not use RequestHandler, and the plugins' other error handling stays as it is. Happy to move it if you prefer that layer.

The new test in test/test_metadata_plugins.py makes get_search_response raise ConnectionError and checks that the error record has the message and no traceback. It fails without the change.

Tests: pytest test/test_metadata_plugins.py test/plugins/test_musicbrainz.py, 73 passed (72 before the new test).

This change was prepared with an AI coding assistant (Claude Code, claude-sonnet-5-5) and reviewed before submission.

To Do

  • Documentation.
  • Changelog.
  • Tests.

When a metadata source such as MusicBrainz is unreachable, _search_api
logged the requests exception with exc_info=True, printing a long
urllib3 traceback for every search. Log the message at error level and
the traceback at debug level for requests exceptions, as
maybe_handle_plugin_error already does.

Fixes #6960
@wolfgang-aura
wolfgang-aura requested review from a team and semohr as code owners October 28, 2026 09:44
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.61%. Comparing base (f2ecff6) to head (0761a3d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beets/metadata_plugins.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7119      +/-   ##
==========================================
- Coverage   80.62%   80.61%   -0.02%     
==========================================
  Files         149      149              
  Lines       21254    21261       +7     
  Branches     3284     3285       +1     
==========================================
+ Hits        17136    17139       +3     
- Misses       3290     3293       +3     
- Partials      828      829       +1     
Files with missing lines Coverage Δ
beets/metadata_plugins.py 91.95% <71.42%> (-0.87%) ⬇️

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

@snejus snejus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks - please run poe format-docs.

@snejus
snejus enabled auto-merge October 29, 2026 19:40
auto-merge was automatically disabled October 30, 2026 02:23

Head branch was pushed to by a user without write access

@snejus
snejus enabled auto-merge November 1, 2026 11:52
@snejus
snejus disabled auto-merge November 1, 2026 12:03
@snejus
snejus merged commit 5ae86d1 into beetbox:master Nov 1, 2026
19 checks passed
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.

Gracefully catch error when MusicBrainz is unreachable

2 participants