beetbox / beetbox/beets

Item as no database error during imports with unmatched tracks

Open
#6,057 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

Since a very long time already I am aware of this error and I'm wondering if anybody else can reproduce it?

In the past I often could not pin down in what situations it happens and often it occurred during (complicated) merges of tracks into one album.

By now I know that I can repro it by simply trying to import an album with an arbitrary/additional track in the folder that is not part of the official album and simply should be ignored (see `Unmatched tracks` output below)

It's pretty frustrating since I can't trust beets anymore to import flawlessly. If it crashes like that I have "half imported" stuff in my database and need to clean that up before doing anything else (usually I `import --copy` but then I would have the original paths in the beets library and have to carefully do a`beet rm -a` that!)

```
Match (74.1%):
Bloodjinn - Murder Eternal: Seven Short Stories For The Slightly Psychotic
≠ album, tracks, unmatched tracks, media, country
Discogs, CD, 2000, US, Tribunal Records, TRB005, None
https://www.discogs.com/release/3361384-Bloodjinn-Murder-Eternal-Seven-Short-Stories-For-The-Slightly-Psychotic
* Artist: Bloodjinn
≠ Album: Murder Eternal -> Murder Eternal: Seven Short Stories For The Slightly Psychotic
≠ (#0) The Adventures Of Johnny Blue (5:08) -> (#1) The Adventures Of Johnny Blue Collar (5:11)
≠ (#0) Seconds (3:47) -> (#2) Seconds (3:50)
≠ (#0) Mezzadan (5:26) -> (#3) Mezzadan (4:36)
≠ (#0) Let Us Know (3:06) -> (#4) Let Us Know Within 30 Days (3:06)
≠ (#0) Broke In A Small Town (5:12) -> (#5) Broke In A Small Town (5:15)
≠ (#0) The Heart That Died (4:15) -> (#6) The Heart That Died... (4:10)
≠ (#0) Forsaken On 52 (9:38) -> (#7) Forsaken On 52 (9:39)
Unmatched tracks (1):
! Bloodjinn - The Adventures of JBC (#115) (5:11)
➜ Apply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates, plaY? a
Traceback (most recent call last):
File "/home/jojo/.pyenv/versions/beets/bin/beet", line 8, in
sys.exit(main())
^^^^^^
File "/home/jojo/git/beets/beets/ui/__init__.py", line 1713, in main
_raw_main(args)
File "/home/jojo/git/beets/beets/ui/__init__.py", line 1692, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/jojo/git/beets/beets/ui/commands.py", line 1378, in import_func
import_files(lib, byte_paths, query)
File "/home/jojo/git/beets/beets/ui/commands.py", line 1322, in import_files
session.run()
File "/home/jojo/git/beets/beets/importer/session.py", line 234, in run
pl.run_parallel(QUEUE_SIZE)
File "/home/jojo/git/beets/beets/util/pipeline.py", line 468, in run_parallel
raise exc_info[1].with_traceback(exc_info[2])
File "/home/jojo/git/beets/beets/util/pipeline.py", line 333, in run
out = self.coro.send(msg)
^^^^^^^^^^^^^^^^^^^
File "/home/jojo/git/beets/beets/util/pipeline.py", line 216, in coro
func(*(args + (task,)))
File "/home/jojo/git/beets/beets/importer/stages.py", line 247, in plugin_stage
func(session, task)
File "/home/jojo/git/beets/beets/plugins.py", line 259, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/jojo/git/beets-dirfields/beetsplug/dirfields.py", line 69, in stage
item.store()
File "/home/jojo/git/beets/beets/library/models.py", line 71, in store
super().store(fields)
File "/home/jojo/git/beets/beets/dbcore/db.py", line 595, in store
db = self._check_db()
^^^^^^^^^^^^^^^^
File "/home/jojo/git/beets/beets/dbcore/db.py", line 424, in _check_db
raise ValueError(f"{type(self).__name__} has no database")
ValueError: Item has no database
```

### Setup

* OS:
* Python version:
* beets version:
* Turning off plugins made problem go away (yes/no): yes

When I only use the discogs plugin and nothing else, the import works, eg like that:

```
beet -p discogs import --copy -I --set toplevel=HardcorePunkMetal /remote/data/music-archive/Hardcore\&Metal/0-ALBUMS/bloodjinn\ -\ murder\ eternal
```

My configuration (output of `beet config`) is:

```yaml
(paste here)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the import using an unmatched track and the dirfields plugin, then trace the call from beets/importer/stages.py through beets/plugins.py to beets-dirfields/beetsplug/dirfields.py:69. Compare this with the working discogs-only command and inspect beets/library/models.py and beets/dbcore/db.py around Item.store(). Done means the import completes without the “Item has no database” failure and does not leave a half-imported database.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.