# Buggy code
def batch_fetch_art(lib, albums, force, maxwidth=None):
    """Fetch album art for each of the albums. This implements the manual
    fetchart CLI command.
    """
    for album in albums:
        if album.artpath and not force:
            message = "has album art"
        else:
            # In ordinary invocations, look for images on the
            # filesystem. When forcing, however, always go to the Web
            # sources.
            local_paths = None if force else [album.path]

            path = art_for_album(album, local_paths, maxwidth)
            if path:
                album.set_art(path, False)
                album.store()
                message = "found album art"
                if config["color"]:
                    message = ui.colorize("red", message)
            else:
                message = "no art found"
                if config["color"]:
                    message = ui.colorize("turquoise", message)

        log.info("{0} - {1}: {2}".format(album.albumartist, album.album, message))


# Traceback (AssertionError)
Tindersticks - Chocolate (from mpc)
lyrics426 ['Tindersticks', ' ', 'Chocolate']
('lib943', [u'Tindersticks', u' ', u'Chocolate'])
('lib859', [u'Tindersticks', u' ', u'Chocolate'])
('lib800', u'Tindersticks')
('lib778', u'Tindersticks')
('lib800', u' ')
('lib778', u' ')
Traceback (most recent call last):
File "/usr/local/bin/beet", line 20, in <module>
beets.ui.main()
File "/home/winters/buildtests/beets/beets/ui/__init__.py", line 815, in main
_raw_main(args)
File "/home/winters/buildtests/beets/beets/ui/__init__.py", line 807, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/winters/buildtests/beets/beetsplug/lyrics.py", line 428, in func
for item in lib.items(ui.decargs(args)):
File "/home/winters/buildtests/beets/beets/library.py", line 965, in items
return self._fetch(Item, query, order)
File "/home/winters/buildtests/beets/beets/library.py", line 946, in _fetch
model_cls, get_query(query, model_cls), order_by
File "/home/winters/buildtests/beets/beets/library.py", line 874, in get_query
return query_from_strings(dbcore.AndQuery, model_cls, val)
File "/home/winters/buildtests/beets/beets/library.py", line 845, in query_from_strings
subq = construct_query_part(part, model_cls)
File "/home/winters/buildtests/beets/beets/library.py", line 805, in  construct_query_part
parsed = parse_query_part(query_part, query_classes, prefixes)
File "/home/winters/buildtests/beets/beets/library.py", line 782, in parse_query_part
assert match  # Regex should always match.
AssertionError

# Fixed code
def batch_fetch_art(lib, albums, force, maxwidth=None):
    """Fetch album art for each of the albums. This implements the manual
    fetchart CLI command.
    """
    for album in albums:
        if album.artpath and not force:
            message = "has album art"
        else:
            # In ordinary invocations, look for images on the
            # filesystem. When forcing, however, always go to the Web
            # sources.
            local_paths = None if force else [album.path]

            path = art_for_album(album, local_paths, maxwidth)
            if path:
                album.set_art(path, False)
                album.store()
                message = ui.colorize("green", "found album art")
            else:
                message = ui.colorize("red", "no art found")

        log.info("{0} - {1}: {2}".format(album.albumartist, album.album, message))