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

Traceback from library.lookup when passing empty list of uris #1619

Closed
kingosticks opened this Issue May 17, 2017 · 0 comments

Comments

2 participants
@kingosticks
Member

kingosticks commented May 17, 2017

Whilst fixing up the tests for another PR I noticed we do not properly handle calling LibraryController.lookup() with an empty list:

$ curl -X POST -H Content-Type:application/json -d '{ "method": "core.library.lookup", "jsonrpc": "2.0", "params": { "uris": [] },  "id": 1 }' http://localhost:6680/mopidy/rpc | json_pp

{
   "jsonrpc" : "2.0",
   "id" : 1,
   "error" : {
      "message" : "Invalid params",
      "code" : -32602,
      "data" : {
         "type" : "TypeError",
         "message" : "'NoneType' object is not iterable",
         "traceback" : "Traceback (most recent call last):\n  File \"/home/nsteel/.virtualenvs/mopidy/local/lib/python2.7/site-packages/mopidy/internal/jsonrpc.py\", line 133, in _handle_single_request\n    result = self._unwrap_result(result)\n  File \"/home/nsteel/.virtualenvs/mopidy/local/lib/python2.7/site-packages/mopidy/internal/jsonrpc.py\", line 222, in _unwrap_result\n    result = result.get()\n  File \"/work/nsteel/projects/mopidy-dev/pykka/pykka/threading.py\", line 52, in get\n    compat.reraise(*self._data['exc_info'])\n  File \"/work/nsteel/projects/mopidy-dev/pykka/pykka/compat.py\", line 12, in reraise\n    exec('raise tp, value, tb')\n  File \"/work/nsteel/projects/mopidy-dev/pykka/pykka/actor.py\", line 201, in _actor_loop\n    response = self._handle_receive(message)\n  File \"/work/nsteel/projects/mopidy-dev/pykka/pykka/actor.py\", line 295, in _handle_receive\n    return callee(*message['args'], **message['kwargs'])\n  File \"/home/nsteel/.virtualenvs/mopidy/local/lib/python2.7/site-packages/mopidy/core/library.py\", line 231, in lookup\n    for u in backend_uris:\nTypeError: 'NoneType' object is not iterable\n"
      }
   }
}
  • LibraryController.get_images(uris=[]) is fine, returns an empty dictionary.
  • LibraryController.search(uris=[]) is also fine, it passes the None type straight to the backend instances which are sure to handle that as it's the parameter's default value.

To fix we just need something similar to what search already has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment