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

click on album in local library results in request for core.library.lookup with "uris": ["undefined"] #250

Closed
mfremont opened this issue Oct 20, 2017 · 2 comments
Labels

Comments

@mfremont
Copy link

Steps:

  1. Browse the local library, navigate to a folder for a specific album
  2. Click the table row with the album title and image

Result:

  1. The web client displays the notice, "Loading data from Mopidy on hostname. Please wait..."
  2. The web client makes a request for core.library.lookup with the "uris" param value["undefined]
  3. Mopidy responds with "Application error" and the detail message, "Expected a list of URIs not u'undefined'"

Request:

{"method":"core.library.lookup","params":{"uris":["undefined"]},"jsonrpc":"2.0","id":32}

Response:

{
   "error": {
     "code": 0,
     "data": {
       "message": "Expected a list of URIs, not u'undefined'",
       "traceback": "Traceback (most recent call last):\n  File \"/home/mrf/.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/mrf/.local/lib/python2.7/site-packages/mopidy/internal/jsonrpc.py\", line 222, in _unwrap_result\n    result = result.get()\n  File \"/home/mrf/.local/lib/python2.7/site-packages/pykka/threading.py\", line 52, in get\n    compat.reraise(*self._data['exc_info'])\n  File \"/home/mrf/.local/lib/python2.7/site-packages/pykka/compat.py\", line 12, in reraise\n    exec('raise tp, value, tb')\n  File \"/home/mrf/.local/lib/python2.7/site-packages/pykka/actor.py\", line 201, in _actor_loop\n    response = self._handle_receive(message)\n  File \"/home/mrf/.local/lib/python2.7/site-packages/pykka/actor.py\", line 295, in _handle_receive\n    return callee(*message['args'], **message['kwargs'])\n  File \"/home/mrf/.local/lib/python2.7/site-packages/mopidy/core/library.py\", line 217, in lookup\n    uris is None or validation.check_uris(uris)\n  File \"/home/mrf/.local/lib/python2.7/site-packages/mopidy/internal/validation.py\", line 105, in check_uris\n    [check_uri(a, msg) for a in arg]\n  File \"/home/mrf/.local/lib/python2.7/site-packages/mopidy/internal/validation.py\", line 100, in check_uri\n    raise exceptions.ValidationError(msg.format(arg=arg))\nValidationError: Expected a list of URIs, not u'undefined'\n",
       "type": "ValidationError"
     },
     "message": "Application error"
   },
   "id": 32,
   "jsonrpc": "2.0"
 }

Additional details and software versions:

BeetsLocal plugin is being used to access the local library.

Mopidy (2.1.0)
Mopidy-BeetsLocal (0.0.9)
Mopidy-MusicBox-Webclient (2.4.0)
Python 2.7.13
Lubuntu 16.04

@jcass77
Copy link
Member

jcass77 commented Apr 11, 2018

Does this error also occur when browsing using the standard Mopidy ‘File’ or ‘Local Media’ backend extensions?

I don’t have the BeetsLocal extension installed but suspect that might be where the issue is originating from.

@mfremont
Copy link
Author

I re-enabled File, Local, and Local SQLite, and then performed a fresh local scan.

With Local SQLite, I can click through the row with the album title in this view:

browse tracks

then the web UI successfully displays an album view:

view album

However, with the File backend, this same sequence instead leaves me with a view like this:

Result of clicking on album row with File backend

With the File backend, the UI makes a JSON RPC request like the example above, with "params": {"uris": ["undefined"]}.

The backend responds with an application error:

{
  "jsonrpc": "2.0",
  "id": 25,
  "error": {
    "message": "Application error",
    "code": 0,
    "data": {
      "message": "Expected a list of URIs, not u'undefined'",
      "traceback": "Traceback (most recent call last):\n  File \"/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py\", line 133, in _handle_single_request\n    result = self._unwrap_result(result)\n  File \"/usr/lib/python2.7/dist-packages/mopidy/internal/jsonrpc.py\", line 222, in _unwrap_result\n    result = result.get()\n  File \"/usr/lib/python2.7/dist-packages/pykka/threading.py\", line 52, in get\n    compat.reraise(*self._data['exc_info'])\n  File \"/usr/lib/python2.7/dist-packages/pykka/compat.py\", line 12, in reraise\n    exec('raise tp, value, tb')\n  File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 201, in _actor_loop\n    response = self._handle_receive(message)\n  File \"/usr/lib/python2.7/dist-packages/pykka/actor.py\", line 295, in _handle_receive\n    return callee(*message['args'], **message['kwargs'])\n  File \"/usr/lib/python2.7/dist-packages/mopidy/core/library.py\", line 217, in lookup\n    uris is None or validation.check_uris(uris)\n  File \"/usr/lib/python2.7/dist-packages/mopidy/internal/validation.py\", line 105, in check_uris\n    [check_uri(a, msg) for a in arg]\n  File \"/usr/lib/python2.7/dist-packages/mopidy/internal/validation.py\", line 100, in check_uri\n    raise exceptions.ValidationError(msg.format(arg=arg))\nValidationError: Expected a list of URIs, not u'undefined'\n",
      "type": "ValidationError"
    }
  }
}

undefined does not appear in the previous request/response pairs, so it's not simply a matter of the backend returning a URI of "undefined".

When I take a closer look at the JSON RPC request/response pairs that precede the error, what jumps out is that the Local SQLite backend responds to a lookup request for a track with a album object that contains a uri property for the album:

{
  "method": "core.library.lookup",
  "params": {
    "uris": [
      "local:track:Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac"
    ]
  },
  "jsonrpc": "2.0",
  "id": 24
}

{
  "jsonrpc": "2.0",
  "id": 24,
  "result": {
    "local:track:Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac": [
      {
        "album": {
          "__model__": "Album",
          "name": "Mos Def & Talib Kweli Are Black Star",
          "num_tracks": 13,
          "uri": "local:album:mbid:66df81d2-9787-3838-85fa-fa0de57990f3",
          "artists": [
            {
              "__model__": "Artist",
              "musicbrainz_id": "02708fd6-0fe6-4738-a27d-0561ace8b4c6",
              "name": "Black Star",
              "uri": "local:artist:md5:99d00d9ec7ef29ad8994a8a89468357d"
            }
          ],
          "date": "2002-06-04",
          "musicbrainz_id": "66df81d2-9787-3838-85fa-fa0de57990f3",
          "num_discs": 1
        },
        "composers": [
          {
            "__model__": "Artist",
            "name": "Mos Def",
            "uri": "local:artist:md5:de41d6c37ecd7fdbb01cdcafeb0dbc16"
          }
        ],
        "__model__": "Track",
        "name": "Intro",
        "disc_no": 1,
        "uri": "local:track:Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac",
        "date": "2002-06-04",
        "length": 71880,
        "last_modified": 1509589770651,
        "track_no": 1,
        "artists": [
          {
            "__model__": "Artist",
            "musicbrainz_id": "02708fd6-0fe6-4738-a27d-0561ace8b4c6",
            "name": "Black Star",
            "uri": "local:artist:md5:99d00d9ec7ef29ad8994a8a89468357d"
          }
        ],
        "genre": "Rap",
        "musicbrainz_id": "d342f41f-d995-4185-92bc-4c2db314e5c5"
      }
    ]
  }
}

whereas the album URI is not present in the File backend response:

{
  "method": "core.library.lookup",
  "params": {
    "uris": [
      "file:///media/Music/Library/Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac"
    ]
  },
  "jsonrpc": "2.0",
  "id": 36
}

{
  "jsonrpc": "2.0",
  "id": 36,
  "result": {
    "file:///media/Music/Library/Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac": [
      {
        "album": {
          "__model__": "Album",
          "name": "Mos Def & Talib Kweli Are Black Star",
          "num_tracks": 13,
          "artists": [
            {
              "__model__": "Artist",
              "musicbrainz_id": "02708fd6-0fe6-4738-a27d-0561ace8b4c6",
              "name": "Black Star"
            }
          ],
          "date": "2002-06-04",
          "musicbrainz_id": "66df81d2-9787-3838-85fa-fa0de57990f3",
          "num_discs": 1
        },
        "composers": [
          {
            "__model__": "Artist",
            "name": "Mos Def"
          }
        ],
        "__model__": "Track",
        "name": "Intro",
        "disc_no": 1,
        "uri": "file:///media/Music/Library/Black%20Star/Mos%20Def%20%26%20Talib%20Kweli%20Are%20Black%20Star/01%20Intro.flac",
        "date": "2002-06-04",
        "length": 71880,
        "track_no": 1,
        "artists": [
          {
            "__model__": "Artist",
            "musicbrainz_id": "02708fd6-0fe6-4738-a27d-0561ace8b4c6",
            "name": "Black Star"
          }
        ],
        "genre": "Rap",
        "musicbrainz_id": "d342f41f-d995-4185-92bc-4c2db314e5c5"
      }
    ]
  }
}

It appears that the issue is triggered when the backend responds to a track lookup with an embedded album object that does not include a uri property. It's not clear to me from the Mopidy API documentation whether uri can be expected to be present and non-empty. But even if the backend is returning an incomplete object, i.e. a backend bug, should it also be the responsibility of the UI to not make a malformed request such as "params": ["undefined"] if the uri property is missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants