Repository navigation
Closed
Labels
Description
When trying to remove this competition (as the primary organizer of the competition), we obtain the following error.
Here is the Django error logs on the platform:
django_1 | Internal Server Error: /api/competitions/1002/
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
django_1 | response = get_response(request)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
django_1 | response = self.process_exception_by_middleware(e, request)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
django_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
django_1 | return view_func(*args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 116, in view
django_1 | return self.dispatch(request, *args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 495, in dispatch
django_1 | response = self.handle_exception(exc)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 455, in handle_exception
django_1 | self.raise_uncaught_exception(exc)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 492, in dispatch
django_1 | response = handler(request, *args, **kwargs)
django_1 | File "/app/src/apps/api/views/competitions.py", line 224, in destroy
django_1 | return super().destroy(request, *args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 93, in destroy
django_1 | self.perform_destroy(instance)
django_1 | File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 97, in perform_destroy
django_1 | instance.delete()
django_1 | File "/app/src/apps/chahub/models.py", line 143, in delete
django_1 | super().delete(*args, **kwargs)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 921, in delete
django_1 | collector.collect([self], keep_parents=keep_parents)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/deletion.py", line 224, in collect
django_1 | field.remote_field.on_delete(self, field, sub_objs, self.using)
django_1 | File "/usr/local/lib/python3.8/site-packages/django/db/models/deletion.py", line 22, in PROTECT
django_1 | raise ProtectedError(
django_1 | django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'Competition' because they are referenced through a protected foreign key: 'Data.competition'", <QuerySet [<Data: fnachalearn - submission(15789)>, <Data: fnachalearn - submission(15790)>]>)I've seen that the organizer was in status "denied" from the competition, but even when approved the bug remains.
I think this log describe the problem:
django_1 | django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'Competition' because they are referenced through a protected foreign key: 'Data.competition'", <QuerySet [<Data: fnachalearn - submission(15789)>, <Data: fnachalearn - submission(15790)>]>)
Activity
Didayolo commentedon Jun 9, 2023
For more context, the "error comp" cannot be deleted after the organizer deleted his submissions by checking the box and select Delete submissions as below:
instead of clicking the red bin:
ihsaan-ullah commentedon Jun 9, 2023
Trying to reproduce this
I think this problem is there because of new addition to data model here:
https://github.com/codalab/codabench/blob/f55e5ccd15027a29a6068e46ae23cf977e231446/src/apps/datasets/models.py#LL61C12-L61C12
changing
models.PROTECTtomodels. CASCADEwill solve the problemDidayolo commentedon Jun 9, 2023
@ihsaan-ullah wow you are getting quicker to fix issues everyday!
I think our automatic tests should have catch this issue. We should add a "delete competition" test.