Can't purge failed files
Steps to reproduce
- Upload content to a library that will cause errors
- Navigate to the libraries overview page
- Attempt to Purge the files
What happens?
A 500 error occurs
What is expected?
The failed files should be purged
Context
Funkwhale version(s) affected: 1.2.8+git.3d1eb2fb
Screen_Recording_2022-11-03_at_11.31.22
Frontend error
{
"message": "Request failed with status code 500",
"name": "AxiosError",
"code": "ERR_BAD_RESPONSE",
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "csrftoken",
"xsrfHeaderName": "X-CSRFToken",
"maxContentLength": -1,
"maxBodyLength": -1,
"env": {
"FormData": null
},
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"X-CSRFToken": "sO55JpEQM6xxlE7G0AiZwq8i0QOByeUaOz1Dq7vTGFBvZy1bOVNglbEwxLCmrodQ"
},
"baseURL": "https://tanukitunes.com/api/v1/",
"method": "post",
"url": "uploads/action/",
"data": "{\"action\":\"delete\",\"objects\":\"all\",\"filters\":{\"import_status\":\"errored\"}}"
},
"request": {},
"response": {
"data": "\n<!doctype html>\n<html lang=\"en\">\n<head>\n <title>Server Error (500)</title>\n</head>\n<body>\n <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n",
"status": 500,
"statusText": "Internal Server Error",
"headers": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "https://tanukitunes.com",
"content-length": "145",
"content-security-policy": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' https://fra1.digitaloceanspaces.com data:; font-src 'self' data:; object-src 'none'; media-src https://fra1.digitaloceanspaces.com 'self' data:; frame-ancestors 'self';",
"content-type": "text/html",
"date": "Thu, 03 Nov 2022 10:31:29 GMT",
"referrer-policy": "same-origin",
"retry-after": "1404",
"server": "nginx",
"vary": "Cookie, Origin",
"x-content-type-options": "nosniff",
"x-firefox-spdy": "h2",
"x-frame-options": "DENY, SAMEORIGIN, SAMEORIGIN",
"x-ratelimit-duration": "3600",
"x-ratelimit-limit": "2000",
"x-ratelimit-remaining": "1952",
"x-ratelimit-reset": "1667475089",
"x-ratelimit-resetseconds": "3600",
"x-ratelimit-scope": "authenticated-wildcard",
"x-xss-protection": "1; mode=block"
},
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "csrftoken",
"xsrfHeaderName": "X-CSRFToken",
"maxContentLength": -1,
"maxBodyLength": -1,
"env": {
"FormData": null
},
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json",
"X-CSRFToken": "sO55JpEQM6xxlE7G0AiZwq8i0QOByeUaOz1Dq7vTGFBvZy1bOVNglbEwxLCmrodQ"
},
"baseURL": "https://tanukitunes.com/api/v1/",
"method": "post",
"url": "uploads/action/",
"data": "{\"action\":\"delete\",\"objects\":\"all\",\"filters\":{\"import_status\":\"errored\"}}"
},
"request": {}
},
"backendErrors": [
"A server error occurred"
],
"isHandled": false
}
Backend error
api_1 | 2022-11-05 12:50:48,689 django.request ERROR Internal Server Error: /api/v1/uploads/action/
api_1 | Traceback (most recent call last):
api_1 | File "/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
api_1 | response = get_response(request)
api_1 | File "/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
api_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
api_1 | File "/venv/lib/python3.10/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
api_1 | return callback(request, *args, **kwargs)
api_1 | File "/usr/lib/python3.10/contextlib.py", line 79, in inner
api_1 | return func(*args, **kwds)
api_1 | File "/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
api_1 | return view_func(*args, **kwargs)
api_1 | File "/venv/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
api_1 | return self.dispatch(request, *args, **kwargs)
api_1 | File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
api_1 | response = self.handle_exception(exc)
api_1 | File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
api_1 | self.raise_uncaught_exception(exc)
api_1 | File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
api_1 | raise exc
api_1 | File "/venv/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
api_1 | response = handler(request, *args, **kwargs)
api_1 | File "/app/funkwhale_api/music/views.py", line 789, in action
api_1 | result = serializer.save()
api_1 | File "/app/funkwhale_api/common/serializers.py", line 174, in save
api_1 | result = handler(self.validated_data["objects"])
api_1 | File "/usr/lib/python3.10/contextlib.py", line 79, in inner
api_1 | return func(*args, **kwds)
api_1 | File "/app/funkwhale_api/music/serializers.py", line 537, in handle_delete
api_1 | return objects.delete()
api_1 | File "/venv/lib/python3.10/site-packages/django/db/models/query.py", line 728, in delete
api_1 | raise TypeError('Cannot call delete() after .distinct().')
api_1 | TypeError: Cannot call delete() after .distinct().
Edited by Ciarán Ainsworth