beets icon indicating copy to clipboard operation
beets copied to clipboard

Bad interaction: fromfilename and edit plugins

Open Vrihub opened this issue 2 months ago • 5 comments

Problem

When using both the fromfilename and edit plugin, aborted/canceled edit operations fail to restore the temporary tag data provided by the fromfilename plugin.

Steps to reproduce

  1. Import some files lacking metadata tags, but containing useful information in the file name
  2. The fromfilename plugin will create tags for track number, artist, title which will be used by the autotagger, e.g. for a search on musicbrainz
  3. Select an album release candidate from the musicbrainz search results. In the "match preview" list, on the lefthand side you can see the files identified by the tags generated by the fromfilename plugin (and on the right side the suggested matches from the candidate release).
  4. Choose "edit Candidates" and quit your text editor without making any changes
  5. Select another candidate (even the same selected in step 3.): now on the lefthand side your files will be identified by the filename, no more info about the track number and titles: those tags generated by the fromfilename plugin are lost.

Notes

  • The same happens if you choose "eDit" in step 4. The resulting text file will be correctly populated with tags from the fromfilename plugin, but if you quit the editor and go to step 5. above, the same bug occurs.
  • The same happens if, instead of quitting the editor without changes, you actually make some changes, save the file, and select "Cancel" in the next menu.
  • Other actions from the import menu don't cause the bug, i.e. I can do multiple searches on musicbrainz by artist/album or release id, and the fromfilename tags are always preserved
  • If I don't use the fromfilename plugin and try to import files that already contain some tags, the bug doesn't happen. Tags coming from the file metadata are correctly remembered across aborted edit sessions, only tags coming from the fromfilename plugin are lost.
  • "Mixed tags case": if I try to import files that contain tags for artist and track number, but non for title: the fromfilename plugin will generate title tags (equal to the track number, that's expected behaviour), and in step 5. the artist and track tags (coming from the file metadata) will be remembered, while the title tag generated by the fromfilename plugin will be lost.

Hints?

I haven't studied the edit plugin yet, but looking at the history, the bug might be related to 9898451 and/or surrounding commits dealing with correctly restoring objects in multiple edit sessions? Maybe the restoring logic should be fixed also in our "Cancel" case?

Or maybe the bug might be in the fromfilename plugin: should it create the temporary tags in a more "robust" way? I don't know much about beets internals to assess this. I can only observe the tags correctly survive to multiple musicbrainz searches (see third note above), they are only lost after aborted edit sessions.

By the way: the edit plugin documentation https://beets.readthedocs.io/en/stable/plugins/edit.html states:

Also, please be aware that the edit Candidates choice can only be used with the matches found during the initial search (and currently not supporting the candidates found via the Enter search or enter Id choices).

it seems this is not true anymore, I can do multiple searches and edit the candidates resulting from each search correctly, so I guess we should update the docs.

Setup

  • OS: Linux
  • Python version: 3.13.5
  • beets version: 2.5.1

Vrihub avatar Oct 17 '25 12:10 Vrihub

Hey team, can I claim this task please? I'm in a software engineering class working on open source projects

gabe-push avatar Nov 04 '25 23:11 gabe-push

@gabe-push You’re very welcome to open a PR and propose a fix for review. We typically don’t assign issues to first-time contributors.

semohr avatar Nov 07 '25 10:11 semohr

Hey @semohr , just opened a PR for this, please let me know if it needs any changes! Thanks https://github.com/beetbox/beets/pull/6200

gabe-push avatar Dec 03 '25 01:12 gabe-push

Hello @henry-oberholtzer , I know this isn't your bug post so I apologize for tagging, but are you able to take a look at this PR please? Thanks in advance for your time!

gabe-push avatar Dec 05 '25 19:12 gabe-push

@gabe-push We have seen this and the PR, no worries! Please be patient. All of us are contributing in our spare time, so the process can take a little longer than we’d like, but rest assured we haven’t forgotten about it 😄

semohr avatar Dec 05 '25 21:12 semohr