beetbox / beetbox/beets

Importer crashes with UnicodeDecodeError on bad input for Artist to "Enter search"

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

Description

### Problem

Running this command in verbose (`-vv`) mode:

```sh
$ beet -vv import \[1995\]\ BPM\ 132/
```

Led to this problem:

If, while in tmux, during an import I hit "e" to select "Enter search" and then in the "Artist:" search I paste in "あぶらだこ", hit BACKSPACE 10 times, and paste in again "あぶらだこ" (I know, contrived and relying on bad behavior or tmux and/or my terminal, but this is how I was able to reliably reproduce, not how I initially encountered the issue) upon hitting enter the entire import crashes.

I realize I'm creating garbage input here, but probably this should still not crash the entire input unrecoverably. Not a huge deal if you're importing only one album, but if this happens in the middle of a huge import it can be really frustrating. Probably just need a try-except and some handling around this.

```
[A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates? e
Artist: あぶらだこ
Traceback (most recent call last):
File "/usr/bin/beet", line 11, in
load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
File "/usr/lib/python3.8/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/usr/lib/python3.8/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/lib/python3.8/site-packages/beets/ui/commands.py", line 955, in import_func
import_files(lib, paths, query)
File "/usr/lib/python3.8/site-packages/beets/ui/commands.py", line 925, in import_files
session.run()
File "/usr/lib/python3.8/site-packages/beets/importer.py", line 329, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/lib/python3.8/site-packages/beets/util/pipeline.py", line 445, in run_parallel
six.reraise(exc_info[0], exc_info[1], exc_info[2])
File "/usr/lib/python3.8/site-packages/six.py", line 703, in reraise
raise value
File "/usr/lib/python3.8/site-packages/beets/util/pipeline.py", line 312, in run
out = self.coro.send(msg)
File "/usr/lib/python3.8/site-packages/beets/util/pipeline.py", line 171, in coro
task = func(*(args + (task,)))
File "/usr/lib/python3.8/site-packages/beets/importer.py", line 1375, in user_query
task.choose_match(session)
File "/usr/lib/python3.8/site-packages/beets/importer.py", line 838, in choose_match
choice = session.choose_match(self)
File "/usr/lib/python3.8/site-packages/beets/ui/commands.py", line 725, in choose_match
post_choice = choice.callback(self, task)
File "/usr/lib/python3.8/site-packages/beets/ui/commands.py", line 647, in manual_search
artist = input_(u'Artist:').strip()
File "/usr/lib/python3.8/site-packages/beets/ui/__init__.py", line 211, in input_
resp = input()
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 3-4: invalid continuation byte
```

Here's a link to the music files that trigger the bug (if relevant):

### Setup

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

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

```yaml
mpd:
port: 6600
host: localhost
password: REDACTED
directory: /vol/data/music
library: /vol/data/musiclibrary.db

plugins: fromfilename duplicates chroma discogs edit export missing mpdupdate
chroma:
auto: yes
duplicates:
count: yes
album: no
checksum: ''
copy: ''
delete: no
format: ''
full: no
keys: []
merge: no
move: ''
path: no
tiebreak: {}
strict: no
tag: ''
mpdupdate:
host: localhost
port: 6600

import:
move: yes
write: yes
incremental: yes
resume: yes
incremental_skip_later: yes
log: beet_import.log
detail: yes
bell: yes

match:
preferred:
countries:
- US
- GB|UK
- JP
- CN
- ES
discogs:
apikey: REDACTED
apisecret: REDACTED
tokenfile: discogs_token.json
source_weight: 0.5
user_token: REDACTED
edit:
albumfields: album albumartist
itemfields: track title artist album
ignore_fields: id path
missing:
count: no
total: no
album: no
export:
default_format: json
json:
formatting:
ensure_ascii: no
indent: 4
separators: [',', ': ']
sort_keys: yes
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.