Repository: beetbox/beets

Issue:
KeyError in new pseudo-release extraction path
Beets is crashing currently when running mbsync on the whole library as well as attempting imports on some albums. It seems to be a problem that was introduced with #4714 with the assumption that res['release'] will be a dict contatining a 'status' key.. This has rendered beets unusable, so I would say is fairly high priority.

### Problem

Running this command in verbose (`-vv`) mode:

```
beet -vv import /downloads/ --from-scratch -t
user configuration: /config/config.yaml
data directory: /config
plugin paths:
fetchart: google: Disabling art source due to missing key
fetchart: lastfm: Disabling art source due to missing key
Sending event: pluginload
library database: /config/musiclibrary.blb
library directory: /music
Sending event: library_opened
Sending event: import_begin
ignoring b'.DS_Store' due to ignore rule b'.*'
ignoring b'.DS_Store@SynoResource' due to ignore rule b'.*'
Sending event: import_task_created
Sending event: import_task_start
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/01 - Countdown.mp3'
chroma: matched recordings ['7536f275-aa69-4bfa-85e2-7641926710ee'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/02 - Dr. Mackintosh.mp3'
chroma: matched recordings ['5770e4ae-adfe-4bf4-be9b-cf532546d32c'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/03 - Hunted.mp3'
chroma: matched recordings ['85d3e364-cd9c-4a76-8352-4842b024f97b'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/04 - Flatline.mp3'
chroma: matched recordings ['4c07b4db-e62b-4d42-ad66-b581b71ea1a3'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/05 - Boyd Brooks.mp3'
chroma: matched recordings ['bec47086-f727-4612-b968-37028cd007dd'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/06 - The Capsule.mp3'
chroma: matched recordings ['4168e6fe-3799-4b61-94fb-d406adce6ecc'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/07 - Vinciguerra.mp3'
chroma: matched recordings ['704d36c4-3bf1-4674-866c-e09a52f629a5'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/08 - Si Vis Pacem.mp3'
chroma: matched recordings ['b1f721e5-83bc-4f42-ba58-c93aaf6e9950'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/09 - Mind Games.mp3'
chroma: matched recordings ['e41fd1e6-bb96-4d80-a17f-8da8ea34b3a1'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/10 - Grim Sky.mp3'
chroma: matched recordings ['6ba0ac7b-2f15-4c12-947a-88582658d408'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/11 - Come Closer.mp3'
chroma: matched recordings ['321e5d96-5b8f-4517-bfe4-99b6e3f48c44'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/12 - Suri.mp3'
chroma: matched recordings ['f3726ea1-b0b9-4194-a118-877b7cb8ec77'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/13 - Atlas.mp3'
chroma: matched recordings ['1d1983d5-0d76-4b4f-ab65-7e4bf8921cbd'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/14 - Resilience.mp3'
chroma: matched recordings ['7b81cd36-c4aa-423a-a943-0bb7547bcd75'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/15 - The Fortress.mp3'
chroma: matched recordings ['fb6033cc-4a1f-4dfc-857c-e56a9423e9be'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/16 - The Hammer and the Scalpel.mp3'
chroma: matched recordings ['b13450dd-211c-41c6-833f-e78cea4a90de'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/17 - 60 Seconds Remaining.mp3'
chroma: matched recordings ['537a16ce-8e9f-49da-b8a8-3e26f5a6162b'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/18 - No Lag.mp3'
chroma: matched recordings ['07e781a9-abcb-4d81-8f7a-1fe9ea54591e'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/19 - 1v5.mp3'
chroma: matched recordings ['524bccf6-f24f-4a0a-8dca-23ce74819b91'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/20 - Like a Tornado.mp3'
chroma: matched recordings ['0c228fd3-6a91-4c4c-8029-564d61ad7846'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/21 - OPFOR Eliminated.mp3'
chroma: matched recordings ['6995dabc-abad-48c8-8ba9-b6ed41fd2f24'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/22 - Preparation Phase.mp3'
chroma: matched recordings ['c1c38287-48e0-4d0b-b09c-6390b3c13042'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/23 - Let Them Come.mp3'
chroma: matched recordings ['e3712f9d-f886-4f1c-bb4c-0cce0092ac88'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
chroma: chroma: fingerprinted b'/downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)/24 - Match Point.mp3'
chroma: matched recordings ['63846c47-f8e0-47e6-8a42-47cbecf811ec'] on releases ['dc80d353-beee-49a8-893c-65a79ed66e6b']
Looking up: /downloads/Various Artists/Rainbow Six Siege_ Year 3 (Original Music from the Rainbow Six Siege Series)
Tagging Various Artists - Rainbow Six Siege: Year 3 (Original Music from the Rainbow Six Siege Series)
No album ID found.
Search terms: Various Artists - Rainbow Six Siege: Year 3 (Original Music from the Rainbow Six Siege Series)
Album might be VA: True
Searching for MusicBrainz releases with: {'release': 'rainbow six siege: year 3 (original music from the rainbow six siege series)', 'artist': 'various artists', 'tracks': '24'}
Requesting MusicBrainz release dc80d353-beee-49a8-893c-65a79ed66e6b
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Jon Opstad, Danny Cocke, Will Bates - Rainbow Six Siege: Year 3 (Original Music from the Rainbow Six Siege Series) (dc80d353-beee-49a8-893c-65a79ed66e6b)
Computing track assignment...
...done.
Success. Distance: 0.04
Requesting MusicBrainz release e225666a-74e2-4dc8-ae00-91153f29686d
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Jon Opstad, Danny Cocke, Paul Haslinger - Rainbow Six Siege: Year 4 (Original Music from the Rainbow Six Siege Series) (e225666a-74e2-4dc8-ae00-91153f29686d)
Computing track assignment...
...done.
Success. Distance: 0.71
Requesting MusicBrainz release 58385d27-918d-41d1-82a1-26b7251c48b8
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Paul Haslinger - Rainbow Six Siege: Year 2 (Original Music from the Rainbow Six Siege Series) (58385d27-918d-41d1-82a1-26b7251c48b8)
Computing track assignment...
...done.
Success. Distance: 0.71
Requesting MusicBrainz release fd602ab2-c8fa-487b-b0be-1b09e54b2306
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_track_extract
Sending event: mb_album_extract
Sending event: albuminfo_received
Candidate: Paul Haslinger - Rainbow Six Siege: Year 1 (Original Music From the Rainbow Six Siege Series) (fd602ab2-c8fa-487b-b0be-1b09e54b2306)
Computing track assignment...
...done.
Success. Distance: 0.70
Requesting MusicBrainz release 7677defa-03cf-49f0-bcf6-7dc7ba39cb72
Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.6.1', 'console_scripts', 'beet')())
  File "/usr/lib/python3.10/site-packages/beets/ui/__init__.py", line 1301, in main
    _raw_main(args)
  File "/usr/lib/python3.10/site-packages/beets/ui/__init__.py", line 1288, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.10/site-packages/beets/ui/commands.py", line 1037, in import_func
    import_files(lib, paths, query)
  File "/usr/lib/python3.10/site-packages/beets/ui/commands.py", line 977, in import_files
    session.run()
  File "/usr/lib/python3.10/site-packages/beets/importer.py", line 345, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/lib/python3.10/site-packages/beets/util/pipeline.py", line 446, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/usr/lib/python3.10/site-packages/beets/util/pipeline.py", line 311, in run
    out = self.coro.send(msg)
  File "/usr/lib/python3.10/site-packages/beets/util/pipeline.py", line 193, in coro
    func(*(args + (task,)))
  File "/usr/lib/python3.10/site-packages/beets/importer.py", line 1436, in lookup_candidates
    task.lookup_candidates()
  File "/usr/lib/python3.10/site-packages/beets/importer.py", line 666, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/usr/lib/python3.10/site-packages/beets/autotag/match.py", line 512, in tag_album
    for matched_candidate in hooks.album_candidates(items,
  File "/usr/lib/python3.10/site-packages/beets/plugins.py", line 573, in decorated
    for v in generator(*args, **kwargs):
  File "/usr/lib/python3.10/site-packages/beets/autotag/hooks.py", line 699, in album_candidates
    yield from invoke_mb(mb.match_album, artist, album, len(items),
  File "/usr/lib/python3.10/site-packages/beets/autotag/mb.py", line 633, in match_album
    albuminfo = album_for_id(release['id'])
  File "/usr/lib/python3.10/site-packages/beets/autotag/mb.py", line 749, in album_for_id
    if res['release']['status'] == 'Pseudo-Release':
KeyError: 'status'
```


### Setup

* OS: Linux
* Python version: 3.10
* beets version: head (docker)



Discussion:

Resolving patch:
diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py
--- a/beets/autotag/mb.py
+++ b/beets/autotag/mb.py
@@ -746,7 +746,7 @@ def album_for_id(releaseid: str) -> Optional[beets.autotag.hooks.AlbumInfo]:
         # resolve linked release relations
         actual_res = None
 
-        if res['release']['status'] == 'Pseudo-Release':
+        if res['release'].get('status') == 'Pseudo-Release':
             actual_res = _find_actual_release_from_pseudo_release(res)
 
     except musicbrainzngs.ResponseError:


Test patch: