mopidy / mopidy-mpd

Mopidy extension for controlling playback from MPD clients
https://mopidy.com/ext/mpd/
Apache License 2.0
98 stars 20 forks source link

AttributeError: 'NoneType' object has no attribute 'replace' #31

Closed arthurlutz closed 4 years ago

arthurlutz commented 4 years ago

Using gmpc and clicking on Database > / > Local media > Release Years it crashed and I get the following in the server logs :

2020-05-25 23:41:07,965 ERROR [10173:MpdSession-15] pykka: Unhandled exception in MpdSession (urn:uuid:1f3967ff-2e48-4119-92ac-11ba6abc40f8):
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 307, in _handle_receive
    return self.on_receive(message)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/network.py", line 443, in on_receive
    self.on_line_received(line)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/session.py", line 32, in on_line_received
    response = self.dispatcher.handle_request(line)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 46, in handle_request
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 77, in _catch_mpd_ack_errors_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 87, in _authenticate_filter
    return self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 106, in _command_list_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 139, in _idle_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 152, in _add_ok_filter
    response = self._call_next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 69, in _call_next_filter
    return next_filter(request, response, filter_chain)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 164, in _call_handler_filter
    response = self._format_response(self._call_handler(request))
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 178, in _call_handler
    return protocol.commands.call(tokens, context=self.context)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/protocol/__init__.py", line 212, in call
    return self.handlers[tokens[0]](context, *tokens[1:])
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/protocol/__init__.py", line 189, in validate
    return func(**callargs)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/protocol/music_db.py", line 389, in lsinfo
    for path, lookup_future in context.browse(uri, recursive=False):
  File "/usr/local/lib/python3.7/dist-packages/mopidy_mpd/dispatcher.py", line 308, in browse
    path = "/".join([base_path, ref.name.replace("/", "")])
AttributeError: 'NoneType' object has no attribute 'replace'
kingosticks commented 4 years ago

Thanks @arthurlutz. I think this happens for you here with Mopidy-Local when there's something unexpected in the track's date tag. Unexpected in this context seems to be anything except a date string in the format YYYY-MM-DD. I'm not sure why we haven't seen more reports of this issue, it seems to have been there a while.

But we can also fix the more generic case here where we are wrongly assuming the name field always exists, when in fact all fields are optional.