Gofven / flowback

Flowback 1st Iteration
GNU General Public License v3.0
3 stars 3 forks source link

DoesNotExist at /group/workgroup/3/leave WorkGroupUser matching query does not exist. #135

Open Kattenelvis opened 2 weeks ago

Kattenelvis commented 2 weeks ago

Traceback (most recent call last): File "D:\Files\flowback-backend\venv\Lib\site-packages\django\core\handlers\exception.py", line 42, in inner response = await get_response(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\django\core\handlers\base.py", line 253, in _get_response_async response = await wrapped_callback(

File "C:\Users\Katte\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\django\views\decorators\csrf.py", line 56, in wrapper_view return view_func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\django\views\generic\base.py", line 104, in view return self.dispatch(request, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\rest_framework\views.py", line 509, in dispatch response = self.handle_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\rest_framework\views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception raise exc ^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\rest_framework\views.py", line 506, in dispatch response = handler(request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\flowback\group\views\group.py", line 326, in post work_group_user_leave(user_id=request.user.id, work_group_id=work_group_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\flowback\group\services\workgroup.py", line 58, in work_group_user_leave WorkGroupUser.objects.get(group_user=group_user, work_group=work_group).delete() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\django\db\models\manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Files\flowback-backend\venv\Lib\site-packages\django\db\models\query.py", line 637, in get raise self.model.DoesNotExist( ^

Gofven commented 2 weeks ago

This shouldn't cause an error, it only occurs when there's no matching query

In this case, your user isn't in the workgroup, hence why you can't leave that workgroup

I've added a new exception handler condition to give a 404 error instead of a 500, also if you get these 404 errors when you shouldn't, it'll give you a traceback in the console (although if you want to i can dump the data into the detail of 404)