Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_images raises ValueError when parsing uri "spotify:directory" #301

Closed
kingosticks opened this issue Feb 10, 2021 · 6 comments
Closed
Labels
C-bug Category: This is a bug good first issue Call for participation

Comments

@kingosticks
Copy link
Member

kingosticks commented Feb 10, 2021

Iris causes this straight away when you go to browse.

HttpServer DEBUG    2021-02-10 00:05:40,784 Received WebSocket message from 127.0.0.1: '{"method":"core.library.get_images","params":{"uris":["file:root","local:directory","orfradio:","soundcloud:directory","spotify:directory","tunein:root"]},"jsonrpc":"2.0","id":13}'
Core-14 ERROR    2021-02-10 00:05:40,789 SpotifyBackend backend caused an exception.
Traceback (most recent call last):
  File "/home/nick/Dev/mopidy-dev/mopidy/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/home/nick/Dev/mopidy-dev/mopidy/mopidy/core/library.py", line 181, in get_images
    if future.get() is None:
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/library.py", line 35, in get_images
    return images.get_images(self._backend._web_client, uris)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 23, in get_images
    uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 23, in <genexpr>
    uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 45, in _parse_uri
    uri_type, uri_id = parsed_uri.path.split(":")[:2]
ValueError: not enough values to unpack (expected 2, got 1)

And similarly:

HttpServer DEBUG    2021-02-10 00:12:54,304 Received WebSocket message from 127.0.0.1: '{"method":"core.library.get_images","params":{"uris":["spotify:playlists:featured"]},"jsonrpc":"2.0","id":19}'
Core-14 ERROR    2021-02-10 00:12:54,306 SpotifyBackend backend caused an exception.
Traceback (most recent call last):
  File "/home/nick/Dev/mopidy-dev/mopidy/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/home/nick/Dev/mopidy-dev/mopidy/mopidy/core/library.py", line 181, in get_images
    if future.get() is None:
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/home/nick/.virtualenvs/mopidy3/lib/python3.8/site-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/library.py", line 35, in get_images
    return images.get_images(self._backend._web_client, uris)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 23, in get_images
    uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 23, in <genexpr>
    uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
  File "/home/nick/Dev/mopidy-dev/mopidy-spotify/mopidy_spotify/images.py", line 59, in _parse_uri
    raise ValueError(f"Could not parse {repr(uri)} as a Spotify URI")
ValueError: Could not parse 'spotify:playlists:featured' as a Spotify URI
@kingosticks kingosticks added the C-bug Category: This is a bug label Feb 10, 2021
@tatealive
Copy link

I am getting the same issue:

mopidy[661]:   File "/usr/lib/python3/dist-packages/mopidy_spotify/library.py", line 35, in get_images
mopidy[661]:     return images.get_images(self._backend._web_client, uris)
mopidy[661]:   File "/usr/lib/python3/dist-packages/mopidy_spotify/images.py", line 23, in get_images
mopidy[661]:     uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
mopidy[661]:   File "/usr/lib/python3/dist-packages/mopidy_spotify/images.py", line 23, in <genexpr>
mopidy[661]:     uris = sorted((_parse_uri(u) for u in uris), key=uri_type_getter)
mopidy[661]:   File "/usr/lib/python3/dist-packages/mopidy_spotify/images.py", line 45, in _parse_uri
mopidy[661]:     uri_type, uri_id = parsed_uri.path.split(":")[:2]
mopidy[661]: ValueError: not enough values to unpack (expected 2, got 1)

@kingosticks
Copy link
Member Author

If someone wants to fix this, they can just handle the exception and return an empty response. We don't need to support returning images for arbitrary browse directories, I think this is a weird thing for a client to request.

@djmattyg007
Copy link
Contributor

It could be analogous to album art?

@kingosticks
Copy link
Member Author

kingosticks commented Mar 11, 2021

I'm talking about virtual directories like the ones in the examples I provided above. What would we return for spotify:featured:playlists, for example?

@djmattyg007
Copy link
Contributor

Right, that doesn’t make sense.

@kingosticks kingosticks added the good first issue Call for participation label Jan 26, 2022
@kingosticks kingosticks added this to the Next Major release milestone Dec 21, 2022
@kingosticks
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug good first issue Call for participation
Projects
None yet
Development

No branches or pull requests

3 participants