Skip to content

fix(discogs): retry malformed search responses - #6912

Open
treyturner wants to merge 1 commit into
beetbox:masterfrom
treyturner:fix/discogs-json-retry
Open

fix(discogs): retry malformed search responses#6912
treyturner wants to merge 1 commit into
beetbox:masterfrom
treyturner:fix/discogs-json-retry

Conversation

@treyturner

@treyturner treyturner commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Retry Discogs searches once when the API returns an invalid JSON response. If the retry also fails, flow through existing error handling. Includes regression tests for successful recovery and retry exhaustion.

Reference: joalla/discogs_client#163

Originating stack trace:

discogs: Error searching Discogs: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.14/site-packages/beets/metadata_plugins.py", line 420, in _search_api
    response_data = self.get_search_response(params)
  File "/usr/local/lib/python3.14/site-packages/beetsplug/discogs/__init__.py", line 297, in get_search_response
    return [r.data for r in results.page(1)]
                            ~~~~~~~~~~~~^^^
  File "/usr/local/lib/python3.14/site-packages/discogs_client/models.py", line 347, in page
    data = self.client._get(self._url_for_page(index))
  File "/usr/local/lib/python3.14/site-packages/discogs_client/client.py", line 115, in _get
    return self._request('GET', url)
           ~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/discogs_client/client.py", line 107, in _request
    body = json.loads(content)
  File "/usr/local/lib/python3.14/json/__init__.py", line 352, in loads
    return _default_decoder.decode(s)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/local/lib/python3.14/json/decoder.py", line 345, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/json/decoder.py", line 363, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Testing

  • Full test suite on Python 3.14
  • Ruff, mypy, and Sphinx lint

To Do

  • Documentation. (If you've added a new command-line flag, for example, find the appropriate page under docs/ to describe it.)
  • Changelog. (Add an entry to docs/changelog.rst to the bottom of one of the lists near the top of the document.)
  • Tests. (Very much encouraged but not strictly required.)

@treyturner
treyturner requested a review from a team as a code owner August 5, 2026 22:19
@github-actions github-actions Bot added the discogs discogs plugin label Aug 5, 2026
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.70%. Comparing base (74c2d98) to head (15359b3).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6912      +/-   ##
==========================================
+ Coverage   75.69%   75.70%   +0.01%     
==========================================
  Files         163      163              
  Lines       21412    21418       +6     
  Branches     3384     3384              
==========================================
+ Hits        16208    16215       +7     
+ Misses       4405     4403       -2     
- Partials      799      800       +1     
Files with missing lines Coverage Δ
beetsplug/discogs/__init__.py 69.48% <100.00%> (+1.48%) ⬆️

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

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

Labels

discogs discogs plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant