Phantom album in database - cannot remove (potentially related to bug #1536)

#1

After some imports, I had to download/replace some of my cover images so I used the following command to embed the new art (as per the docs):

beet -vv fetchart ^art_source:filesystem

This resulted in the following error:

fetchart: Randy Newman - Sail Away: has album art
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.8', 'console_scripts', 'beet')()
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/lib/python3.6/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.6/site-packages/beetsplug/fetchart.py", line 896, in func
    opts.quiet)
  File "/usr/lib/python3.6/site-packages/beetsplug/fetchart.py", line 950, in batch_fetch_art
    local_paths = None if force else [album.path]
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 465, in __getattr__
    return self[key]
  File "/usr/lib/python3.6/site-packages/beets/dbcore/db.py", line 354, in __getitem__
    return getters[key](self)
  File "/usr/lib/python3.6/site-packages/beets/library.py", line 1101, in item_dir
    raise ValueError(u'empty album')
ValueError: empty album

After some Googling, I found the following bug report which seems to match my problem:

I’ve noticed that beets iterates though albums/artists alphabetically so I was able to determine the album that triggers the error.

# beet list -a | grep Newsboys
Newsboys - Adoration: The Worship Album

I can confirm that this album is NOT in my filesystem. I recall deleting it after importing it (and running beet update to remove it). Regardless, I tried to delete it with the following command:

/config # beet -vv remove album:Adoration
user configuration: /config/config.yaml
data directory: /config
plugin paths: 
Sending event: pluginload
inline: adding item field multidisc
library database: /config/library.db
library directory: /music
Sending event: library_opened
error: No matching items found.

So it appears that this album is in the beets database, but I am unable to delete it. Any ideas on how to fix this without having to recreate the database? Following is my version info and stats:

# beet version
beets version 1.4.8
Python version 3.6.8
plugins: acousticbrainz, chroma, convert, discogs, duplicates, edit, embedart, fetchart, ftintitle, inline, lastgenre, lyrics, missing, permissions, replaygain, scrub, the, zero

# beet stats -e
Tracks: 36621
Total time: 14.6 weeks (8827724.74 seconds)
Total size: 310.3 GiB (333227998055 bytes)
Artists: 5432
Albums: 1508
Album artists: 293
#2

I want to post an update on this. I used DB Browser for SQLite (https://sqlitebrowser.org/dl/) to view library.db. I found the missing album (in the album table) and, after deleting it, fetchart now works without fail. I suspect that when I ran beet update (after deleting the album) the individual songs/items were removed from the database but not the album itself. I’ll post a follow-up to bug #1536 to help people in the future searching for this error.

#3

That’s super weird and quite bad! Is there any chance you know how to reproduce the problem for a new album? If you can do it reliably, that would be really helpful in understanding what’s going wrong in the #1536 case.