Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/sentry/api/endpoints/debug_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,11 @@ def delete(self, request: Request, project: Project) -> Response:
:qparam string id: The id of the DIF to delete.
:auth: required
"""
if request.GET.get("id") and _has_delete_permission(request.access, project):
debug_file_id = request.GET.get("id")
if debug_file_id and _has_delete_permission(request.access, project):
with atomic_transaction(using=router.db_for_write(File)):
debug_file = (
ProjectDebugFile.objects.filter(id=request.GET.get("id"), project_id=project.id)
ProjectDebugFile.objects.filter(id=debug_file_id, project_id=project.id)
.select_related("file")
.first()
)
Expand Down
8 changes: 8 additions & 0 deletions tests/sentry/api/endpoints/test_debug_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ def test_dsyms_requests(self) -> None:
assert response.status_code == 204, response.content
assert ProjectDebugFile.objects.count() == 0

def test_delete_without_id_returns_404(self) -> None:
response = self._upload_proguard(self.url, PROGUARD_UUID)
assert response.status_code == 201

response = self.client.delete(self.url)
assert response.status_code == 404, response.content
assert ProjectDebugFile.objects.count() == 1

def test_dsyms_as_team_admin(self) -> None:
response = self._upload_proguard(self.url, PROGUARD_UUID)
assert response.status_code == 201
Expand Down
Loading