Skip to content

Tasks API - refuse to delete a task that submissions have been run on - #2648

Merged
Didayolo merged 2 commits into
codalab:protect-task-with-submissionsfrom
bruAristimunha:protect-task-with-submissions
Dec 2, 2026
Merged

Didayolo merged 2 commits into
codalab:protect-task-with-submissionsfrom
bruAristimunha:protect-task-with-submissions

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Root cause of the n/a leaderboard problem we hit on eeg2025 (see #2636 / #2637 discussion): not the task replacement but the task deletion.

Submission.task is on_delete=SET_NULL. Deleting a task sets task=None on every submission scored on it, so:

The UI never triggers this because check_delete_permissions refuses to delete a task that is still in a phase. But a script that (1) swaps the phase to a new task and then (2) deletes the old task passes that check. Updating a task in place through the UI/API works fine, as @sylvchev noted.

This PR adds the same guard for submissions, in destroy and delete_many:

Cannot delete task: submissions have been run on it. Remove it from the phase instead.

No migration, no behaviour change for tasks without submissions. Organizers who want fresh scores on a new task can keep the old task around (it only costs the row) and use re-run/resubmit (#2644) or edit the task in place.

Issues this PR resolves

A checklist for hand testing

  • Create a competition, make a submission on its phase task
  • As the task owner, replace the phase task with a new one in the competition editor
  • Try to delete the old task from the Tasks page or via DELETE /api/tasks/{id}/: refused with the message above
  • A task that has no submissions can still be deleted

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • Ready to merge

Submission.task is SET_NULL, so deleting a task erases which task every
submission scored on it ran on: the leaderboard shows n/a with no history
and the submission can no longer be re-run. The UI never hits this because
a task in a phase cannot be deleted, but a script that first replaces the
phase task and then deletes the old one passes that check. Guard on
submissions like we already guard on phases, in destroy and delete_many.

Related to codalab#2636 codalab#2637
@sylvchev

Copy link
Copy Markdown

I agree that this will help to have the same failsafe than with UI

@Didayolo

Didayolo commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

I think this should be a warning or confirmation popup, not a hard limitation. In the current form, it basically becomes impossible to delete a task.

In the otherhand, a task is just made of pointers and do not take up any storage, so it may be fine.

@Didayolo
Didayolo changed the base branch from develop to protect-task-with-submissions December 2, 2026 02:08
@Didayolo
Didayolo merged commit e0abbe4 into codalab:protect-task-with-submissions Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants