diff --git a/api/funkwhale_api/subsonic/views.py b/api/funkwhale_api/subsonic/views.py index bb5f44166..de7284cd6 100644 --- a/api/funkwhale_api/subsonic/views.py +++ b/api/funkwhale_api/subsonic/views.py @@ -38,7 +38,7 @@ def find_object(queryset, model_field="pk", field="id", cast=int): ) try: value = cast(raw_value) - except (TypeError, ValidationError): + except (ValueError, TypeError, ValidationError): return response.Response( { "error": { diff --git a/api/tests/subsonic/test_views.py b/api/tests/subsonic/test_views.py index b7431efab..d9b50d3eb 100644 --- a/api/tests/subsonic/test_views.py +++ b/api/tests/subsonic/test_views.py @@ -102,6 +102,17 @@ def test_get_artist(f, db, logged_in_api_client, factories): assert response.data == expected +@pytest.mark.parametrize("f", ["xml", "json"]) +def test_get_invalid_artist(f, db, logged_in_api_client, factories): + url = reverse("api:subsonic-get-artist") + assert url.endswith("getArtist") is True + expected = {"error": {"code": 0, "message": 'For input string "asdf"'}} + response = logged_in_api_client.get(url, {"id": "asdf"}) + + assert response.status_code == 200 + assert response.data == expected + + @pytest.mark.parametrize("f", ["xml", "json"]) def test_get_artist_info2(f, db, logged_in_api_client, factories): url = reverse("api:subsonic-get-artist-info2")