Skip to content

Conversation

@snejus
Copy link
Member

@snejus snejus commented Dec 29, 2025

Fixes #6248

@snejus snejus requested a review from semohr December 29, 2025 16:56
@snejus snejus requested a review from a team as a code owner December 29, 2025 16:56
@snejus snejus requested a review from JOJ0 December 29, 2025 16:56
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Accessing rel["release"]["id"] assumes both keys are always present; consider using .get with a defensive fallback or an early-continue to avoid a KeyError on unexpected MusicBrainz responses.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Accessing `rel["release"]["id"]` assumes both keys are always present; consider using `.get` with a defensive fallback or an early-continue to avoid a `KeyError` on unexpected MusicBrainz responses.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@snejus snejus force-pushed the fix-musicbrainz-key-error branch from f1c7064 to f9c3aae Compare December 29, 2025 17:05
@snejus snejus enabled auto-merge December 29, 2025 17:09
@UtkarshVerma
Copy link

Thanks for the quick fix. It doesn't crash anymore. A quick side question, is it normal for beet import -L to not suggest pseudo releases? I can see this release group on Musicbrainz but beets just picks up the Kanji.

https://musicbrainz.org/release-group/0c522c35-de39-4c7c-8bc4-0c33ed02f224

Based on the docs, I think I have the config right.

plugins:
  - convert
  - fetchart
  - embedart
  - lastgenre
  - lyrics
  - duplicates
  - replaygain
  - mbsync
  - scrub
  - zero

  # Autotaggers.
  - chroma
  - mbpseudo
  - fromfilename

directory: ~/music
library: ~/music/library.db

convert:
  auto: true  # Automatically transcode non-MP3 files.
  never_convert_lossy_files: true
  delete_originals: true
  format: opus
  formats:
    opus:
      command: opus-transcode $source $dest

lyrics:
  synced: true  # Prefer synced lyrics.
  sources:
    # - google
    - lrclib

replaygain:
  backend: gstreamer

import:
  move: true
  languages: en  # Prefer English aliases.

mbpseudo:
  scripts:
    - Latn

zero:
  fields: comments
  update_database: true

@snejus snejus merged commit ed566eb into master Dec 29, 2025
19 checks passed
@snejus snejus deleted the fix-musicbrainz-key-error branch December 29, 2025 17:11
@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.24%. Comparing base (21e6a1f) to head (f9c3aae).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6250   +/-   ##
=======================================
  Coverage   68.24%   68.24%           
=======================================
  Files         138      138           
  Lines       18781    18781           
  Branches     3163     3163           
=======================================
  Hits        12817    12817           
  Misses       5291     5291           
  Partials      673      673           
Files with missing lines Coverage Δ
beetsplug/musicbrainz.py 81.15% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@snejus
Copy link
Member Author

snejus commented Dec 29, 2025

@UtkarshVerma ideally, I think, we would like to return both the original and pseudo release as two different candidates. Is this what you would expect to see?

@UtkarshVerma
Copy link

UtkarshVerma commented Dec 29, 2025

@snejus Yes, I would expect to see them both but this is what is happening so far:

$  beet import -L "album:haruhayuku marie"

/home/user/music/Aimer/haruhayuku marie (1 items)

  Match (82.7%):
  Aimer - haruhayuku marie
  ≠ missing tracks, data source, tracks
  MusicBrainz, Digital Media, 2020, None, SME Records, [none], Spotify exclusive
  https://musicbrainz.org/release/e3f7a78d-afa6-4b45-bf3d-08638f93db73
  * Artist: Aimer
  * Album: haruhayuku marie
Missing tracks (3/4 - 75.0%):
 ! marie (#2) (5:07)
 ! Run Riot (#3) (4:16)
 ! 花の唄 end of spring ver. (#4) (5:51)[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? 

Based on this page:
https://musicbrainz.org/release-group/0c522c35-de39-4c7c-8bc4-0c33ed02f224

I expect at least one more release for the translation, but it never shows up, sadly. If it's okay with you can we move this to a discussion or IRC?

Thanks!

@snejus
Copy link
Member Author

snejus commented Dec 29, 2025

No worries, I guess I can just say that support for this is in progress: #6163

@UtkarshVerma
Copy link

Great, nice to see that it's already being worked on. Will wait for the changes to get merged. Thanks!

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.

beet import crashes with KeyError: 'target'

4 participants