# Buggy code
def playlist_uri_from_name(self, name):
    """
    Helper function to retrieve a playlist URI from its unique MPD name.
    """
    if not self._uri_from_name:
        self.refresh_playlists_mapping()
    return self._uri_from_name.get(name)


# Traceback (ValidationError)
2015-12-04 23:41:33,959 ERROR    [MpdSession-13] /home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/actor.py:269
pykka Unhandled exception in MpdSession (urn:uuid:093fbff0-33df-4e39-ba0b-c7259431372c):
Traceback (most recent call last):
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/actor.py", line 304, in _handle_receive
return self.on_receive(message)
File "/home/adamcik/dev/mopidy/mopidy/internal/network.py", line 370, in on_receive
self.on_line_received(line)
File "/home/adamcik/dev/mopidy/mopidy/mpd/session.py", line 34, in on_line_received
response = self.dispatcher.handle_request(line)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 47, in handle_request
return self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 76, in _catch_mpd_ack_errors_filter
return self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 89, in _authenticate_filter
return self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 105, in _command_list_filter
response = self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 134, in _idle_filter
response = self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 147, in _add_ok_filter
response = self._call_next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 68, in _call_next_filter
return next_filter(request, response, filter_chain)
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 159, in _call_handler_filter
response = self._format_response(self._call_handler(request))
File "/home/adamcik/dev/mopidy/mopidy/mpd/dispatcher.py", line 174, in _call_handler
return protocol.commands.call(tokens, context=self.context)
File "/home/adamcik/dev/mopidy/mopidy/mpd/protocol/__init__.py", line 180, in call
return self.handlers[tokens[0]](context, *tokens[1:])
File "/home/adamcik/dev/mopidy/mopidy/mpd/protocol/__init__.py", line 158, in validate
return func(**callargs)
File "/home/adamcik/dev/mopidy/mopidy/mpd/protocol/stored_playlists.py", line 331, in rm
context.core.playlists.delete(uri).get()
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/threading.py", line 52, in get
compat.reraise(*self._data['exc_info'])
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/compat.py", line 12, in reraise
exec('raise tp, value, tb')
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/actor.py", line 201, in _actor_loop
response = self._handle_receive(message)
File "/home/adamcik/dev/mopidy-virtualenv/local/lib/python2.7/site-packages/pykka/actor.py", line 295, in _handle_receive
return callee(*message['args'], **message['kwargs'])
File "/home/adamcik/dev/mopidy/mopidy/core/playlists.py", line 176, in delete
validation.check_uri(uri)
File "/home/adamcik/dev/mopidy/mopidy/internal/validation.py", line 98, in check_uri
raise exceptions.ValidationError(msg.format(arg=arg))
ValidationError: Expected a valid URI, not None

# Fixed code
def playlist_uri_from_name(self, name):
    """
    Helper function to retrieve a playlist URI from its unique MPD name.
    """
    if name not in self._uri_from_name:
        self.refresh_playlists_mapping()
    return self._uri_from_name.get(name)