If a solution exists but we want to remove it it should be deleted from the remote#200
If a solution exists but we want to remove it it should be deleted from the remote#200
Conversation
ColdHeat
commented
Feb 26, 2026
- Handle situation where an admin wants to remove solutions
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to delete remote solutions when they are removed locally, addressing a gap where previously, removing a solution configuration from the local challenge would leave the solution on the remote server.
Changes:
- Adds logic to delete existing remote solutions when no local solution is defined or the solution file is missing
- Implements the deletion check before attempting to create/update the solution
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| resolved_solution = self._resolve_solution_path() | ||
| if not resolved_solution: | ||
| self._delete_existing_solution() |
There was a problem hiding this comment.
The solution sync logic has inefficiencies and inconsistencies compared to other fields:
-
Duplicate path resolution:
_resolve_solution_path()is called twice - once here and once inside_create_solution(). This happens in both cases (solution exists or not). -
Pattern inconsistency: This doesn't follow the established pattern used for flags (lines 847-850), topics (lines 853-856), tags (lines 859-862), and hints (lines 907-910), which always delete then conditionally create.
Consider restructuring to match the established pattern:
- Always call
_delete_existing_solution() - Conditionally call
_create_solution()(which already returns early if no solution)
This would eliminate the duplicate path resolution and improve code consistency.
| resolved_solution = self._resolve_solution_path() | |
| if not resolved_solution: | |
| self._delete_existing_solution() | |
| self._delete_existing_solution() |
| resolved_solution = self._resolve_solution_path() | ||
| if not resolved_solution: | ||
| self._delete_existing_solution() | ||
| self._create_solution() |
There was a problem hiding this comment.
The new behavior to delete existing solutions when no local solution is defined lacks test coverage. Given that the TestSyncChallenge class has comprehensive tests for similar delete-on-removal behavior for other fields (flags, topics, tags, hints, files), a test should be added for solutions as well.
Consider adding a test that:
- Sets up a challenge with an existing remote solution
- Syncs with no local solution defined (or solution file missing)
- Verifies that the delete API call is made to remove the remote solution
| self._create_solution() | |
| else: | |
| self._create_solution() |