beets icon indicating copy to clipboard operation
beets copied to clipboard

MPDStats Shell Parameters --host crashes the Application: AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

Open ss2 opened this issue 1 year ago • 2 comments

I noticed that the plugin mpdstats has problems accepting shell parameters while invoking. Passing the parameter --host=HOST will crash the application:

[user@HOST ~]$ beet -vv -p mpdstats mpdstats --host=localhost
no user configuration found at /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths:
Sending event: pluginload
library database: /home/user/.config/beets/library.db
library directory: /home/user/Music
Sending event: library_opened
Traceback (most recent call last):
  File "/usr/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.12/site-packages/beetsplug/mpdstats.py", line 371, in func
    mpd_config["host"] = opts.host.decode("utf-8")
                         ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

If I put the parameters for this plugin into config.yml, then beets will load the plugin just fine. But a mixture probably is not a good idea. I thought, I'd pass the hostname to config.yml and the port number through the CLI to bypass this error. Then I get the following effect:

First the config:

plugins: mpdstats
mpd:
  host: somehost

The Result:

[user@HOST beets]$ beet -vv -p mpdstats mpdstats --port=5000
user configuration: /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths:
Sending event: pluginload
library database: /home/user/.config/beets/library.db
library directory: /home/user/Music
Sending event: library_opened
mpdstats: music_directory: /home/user/Music
mpdstats: strip_path: /
configuration error: mpd.host: must be a string

I observe this behavior in v1.6.0 and v2.0.0.

Setup

  • OS: Arch Linux
  • Python version: 3.12.5
  • beets version: 2.0.0
  • Turning off plugins made problem go away: Beets is configured with just the one plugin.

I'm surprised about the version reported by beets itself:

[user@HOST beets]$ pacman -Qs beets
local/beets 2.0.0-1
    Flexible music library manager and tagger
[user@HOST beets]$ beet --version
beets version 1.6.1
Python version 3.12.5
plugins: mpdstats

My configuration (output of beet config) is:


# --------------- Plugins ---------------

plugins: mpdstats
mpd:
    host: somehost
    music_directory: /home/user/Music
    strip_path: ''
    rating: yes
    rating_mix: 0.75
    port: 6600
    password: REDACTED


ss2 avatar Sep 03 '24 11:09 ss2

If beet --version looks wrong, check which beet -- maybe you have a local Pip-based installation that is overriding the system-wide installation.

bal-e avatar Oct 12 '24 20:10 bal-e

Okay, that's actually a weird bug in itself. The Arch Linux beets package fetches the commit tagged v2.0.0, which is commit b88c09720c3f0782b90f83df74e65680c050392f. Within that commit, the __init__.py specifies version 1.6.1 instead of 2.0.0. @snejus do you know about this?

bal-e avatar Oct 12 '24 20:10 bal-e

Yup - this issue issue had to do with the release workflow. It bumped the version and committed it, however that commit was not being taken into account in the next step where the distribution was built.

Thus all the new code was packaged under 1.6.1 and pushed upstream. Weirdly though, PyPI was happy with 😅 When I encountered the same issue last night PyPI errored out because I tried pushing 2.0.0 up which already existed.

snejus avatar Nov 23 '24 21:11 snejus