beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.97k stars 1.83k forks source link

Using Inline to [re]define default fields causes "maximum recursion depth exceeded" #2612

Open RollingStar opened 7 years ago

RollingStar commented 7 years ago

Problem

Another semi-silly one. Users can probably guess that this is a bad idea, but I tried it anyway.

This happens after telling import to [R]emove old:

[many more lines like the following]
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 237, in __getitem__
    return getters[key](self)
  File "beets\beetsplug\inline.py", line 120, in _func_func
    func.__globals__.update(_dict_for(obj))
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 237, in __getitem__
    return getters[key](self)
  File "beets\beetsplug\inline.py", line 120, in _func_func
    func.__globals__.update(_dict_for(obj))
  File "beets\beetsplug\inline.py", line 102, in _dict_for
    out = dict(obj)
  File "beets\beets\dbcore\db.py", line 281, in keys
    base_keys = list(self._fields) + list(self._values_flex.keys())
RecursionError: maximum recursion depth exceeded while calling a Python object

Led to this problem:

album_fields:
   album: |
        return 'asdf'

Setup

When I have beets like this, it lists two "album" fields in beet fields.

Potential fix

Maybe quit beets with an error message about using the same fields as beets defaults?

sampsyo commented 7 years ago

Thanks! That's a pretty clear problem: to compute the value of album, beets is trying to use the value of album. 🙄 We may even be able to support this by cutting the recursion cycle.

zhelezov commented 7 years ago

Just stumbled upon this issue after trying the following:

item_fields:
    original_year: original_year if original_year > 0 else year
album_fields:
    original_year: original_year if original_year > 0 else year

So, the only workaround to fix a missing value is adding a custom field?

sampsyo commented 7 years ago

Indeed; choosing a new name will work.

jslpc commented 4 months ago

Just a heads up, this also affects beet update. Had to disable the inline plugin entirely to get anything to work again.