mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-03 21:39:22 +00:00
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:
1 parent
d9061d5e55
commit
02008e40d8
2 files changed
+79
-1
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user