mopidy-spotify icon indicating copy to clipboard operation
mopidy-spotify copied to clipboard

If request fails, error handling causes crash

Open alycejenni opened this issue 5 years ago • 1 comments

If request is None, request.get() will fail and the entire plugin crashes. Mopidy itself will still run, but mopidy-spotify isn't loaded.

Relevant line: https://github.com/mopidy/mopidy-spotify/blob/7bacf57e70454a57e962c0566bf510b485d76193/mopidy_spotify/web.py#L101 (in my local copy I've added request = request or {} after the if, which works fine)

Relevant logs:

2020-11-11 14:29:32,543 INFO [691374:SpotifyEventLoop] spotify.session: Spotify logged in
2020-11-11 14:29:32,543 INFO [691374:SpotifyEventLoop] mopidy_spotify.backend: Logged in to Spotify in online mode
2020-11-11 14:29:32,754 INFO [691374:SpotifyBackend-7] mopidy_spotify.web: Logged into Spotify Web API as username
2020-11-11 14:30:13,320 ERROR [691374:SpotifyBackend-7] pykka: Unhandled exception in SpotifyBackend (urn:uuid:...):
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/pykka/_actor.py", line 186, in _actor_loop
    self.on_start()
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/backend.py", line 68, in on_start
    self.playlists.refresh()
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/playlists.py", line 61, in refresh
    self._get_playlist(playlist_ref.uri)
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/playlists.py", line 44, in _get_playlist
    return playlist_lookup(
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/playlists.py", line 82, in playlist_lookup
    web_playlist = web_client.get_playlist(uri)
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/web.py", line 463, in get_playlist
    for page in track_pages:
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/web.py", line 417, in get_all
    result = self.get_one(path, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/web.py", line 411, in get_one
    result = self.get(path, cache=self._cache, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/mopidy_spotify/web.py", line 100, in get
    "Spotify Web API request failed: "
AttributeError: 'NoneType' object has no attribute 'get'
2020-11-11 14:30:13,324 ERROR [691374:MainThread] mopidy.commands: Actor died: SpotifyBackend (urn:uuid:...) stopped before handling the message
2020-11-11 14:30:13,325 INFO [691374:MainThread] mopidy.commands: Starting Mopidy core

alycejenni avatar Nov 11 '20 14:11 alycejenni

Thanks for reporting this!

jodal avatar Nov 21 '20 21:11 jodal

Fixed in https://github.com/mopidy/mopidy-spotify/pull/342/commits/8150fbb1ec469f60fff6b6d47d46616defebae00

kingosticks avatar Dec 21 '22 12:12 kingosticks