Fix Discogs search retry on malformed JSON - #6918
Closed
KKhandelwal1733 wants to merge 1 commit into
Closed
Conversation
File: beetsplug/discogs/__init__.py
|
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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6918 +/- ##
==========================================
- Coverage 75.69% 75.68% -0.02%
==========================================
Files 163 163
Lines 21412 21415 +3
Branches 3384 3384
==========================================
Hits 16208 16208
- Misses 4405 4408 +3
Partials 799 799
🚀 New features to boost your workflow:
|
Contributor
|
Have you had a chance to discuss this with @treyturner? We generally follow a first-come, first-served approach, and since there’s already a PR addressing this issue, I think it makes sense to continue with the existing one and avoid duplicating the work. I’ll close this PR for now, but you’re more than welcome to review the existing PR, share your thoughts or suggestions there, and help give it some traction. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6912
Problem
The Discogs plugin crashes when the Discogs API returns a malformed JSON response during a search. The
json.loadscall raisesJSONDecodeError, which propagates up and aborts the metadata lookup.Solution
Wrap the search request in a
try/exceptblock that catchesjson.JSONDecodeError. On the first failure, retry the request once. If the retry also fails, re‑raise the original exception so existing error handling takes over.Changes
beetsplug/discogs/__init__.py— added retry logic around the API call, importedjsonfor the exception type, and documented the behavior.Testing