Skip to content

Do not delete the genres tag when musicbrainz.genres is False.#6513

Open
djl wants to merge 1 commit intobeetbox:masterfrom
djl:mbsync-exclude-fields
Open

Do not delete the genres tag when musicbrainz.genres is False.#6513
djl wants to merge 1 commit intobeetbox:masterfrom
djl:mbsync-exclude-fields

Conversation

@djl
Copy link
Copy Markdown
Member

@djl djl commented Apr 9, 2026

Description

Fixes #6403

This commit also introduces a way to explicitly exclude fields from being updated when mbsync runs.

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

@djl djl requested a review from a team as a code owner April 9, 2026 08:43
@github-actions github-actions bot added the musicbrainz musicbrainz plugin label Apr 9, 2026
@djl djl force-pushed the mbsync-exclude-fields branch from 2662d45 to d5909b6 Compare April 9, 2026 08:47
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6513      +/-   ##
==========================================
+ Coverage   70.40%   70.42%   +0.02%     
==========================================
  Files         148      148              
  Lines       18806    18819      +13     
  Branches     3067     3071       +4     
==========================================
+ Hits        13240    13253      +13     
  Misses       4916     4916              
  Partials      650      650              
Files with missing lines Coverage Δ
beetsplug/mbsync.py 84.94% <100.00%> (+2.44%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Fixes beetbox#6403

This commit also introduces a way to explicitly exclude fields from
being updated when mbsync runs.
@djl djl force-pushed the mbsync-exclude-fields branch from d451c62 to 7668260 Compare April 11, 2026 09:01
@snejus
Copy link
Copy Markdown
Member

snejus commented Apr 11, 2026

Given that the bug seems to stem from the musicbrainz plugin, I expected the fix to be there. Using excluded fields in this seems to be a workaround, rather than a solution. For example, if I do not use mbsync but rather reimport music with beet import -LI, presumably we will still have the same issue?

@djl
Copy link
Copy Markdown
Member Author

djl commented Apr 11, 2026

Ah I didn't think about re-importing. That will still show the same issue. I'll move the fix over to the musicbrainz plugin.

@snejus
Copy link
Copy Markdown
Member

snejus commented Apr 11, 2026

I had a look at the source code: it doesn't seem that genres field even gets set when musicbrainz.genres is False. In this case pre-existing genres should not be overwritten.

Are you able to reproduce this issue when reimporting?

@djl
Copy link
Copy Markdown
Member Author

djl commented Apr 11, 2026

So I think this happens because the genres field on the data returned by musicbrainz plugin is None, which results in the existing genres being also set to None. This would mean it's not an issue with the musicbrainz plugin directly but would happen with any field that is different from existing data.

Here I updated the musicbrainz plugin to set info.country = None:

$ bq mbsync -p Këkht Aräkh pale
Këkht Aräkh - Pale Swordsman - Intro
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Thorns
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Night Descends
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - In the Garden
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Amor
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Nocturne
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Amid the Stars
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Lily
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Crystal
  country: XW ->
  genres:
    - black metal
Këkht Aräkh - Pale Swordsman - Swordsman
  country: XW ->
  genres:
    - black metal

If this is an issue beyond just the musicbrainz plugin, my immediate thought for a solution would be to have a way for a metadata plugin to say "I have nothing for this field, use any existing data". Something other than None, which could mean that, but also mean "this should be set to null".

And yes, this does happen on re-importing.

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

Labels

musicbrainz musicbrainz plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Musicbrainz genres deleted using mbsync after https://github.com/beetbox/beets/pull/6401

2 participants