fix: Return HTTP 400 instead of HTTP 500 on DELETE /api/documents/{id}/notes/ with missing or invalid note id (#12582)

This commit is contained in:
Gaëtan GOUZI authored and GitHub committed 2026-04-15 11:56:15 -07:00
1 parent d9061d5e55
commit 02008e40d8
2 files changed
+79 -1

No files matched your search

+8 -1
View File
@@ -1502,7 +1502,14 @@ class DocumentViewSet(
):
return HttpResponseForbidden("Insufficient permissions to delete notes")
note = Note.objects.get(id=int(request.GET.get("id")), document=doc)
note_id = request.GET.get("id")
if not note_id:
raise ValidationError({"id": "This field is required."})
try:
note_id_int = int(note_id)
except ValueError:
raise ValidationError({"id": "A valid integer is required."})
note = get_object_or_404(Note, id=note_id_int, document=doc)
if settings.AUDIT_LOG_ENABLED:
LogEntry.objects.log_create(
instance=doc,