mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-09-14 13:47:58 +00:00
Fix: resolve silent duplication from rebase onto fix/bulk_edit
Rebasing onto origin/fix/bulk_edit (PR #14083, which independently bounds the edit_pdf doc index via manual checks) applied cleanly with no reported conflicts, but left two copies of the same "doc index is out of bounds" check back to back in both EditPdfDocumentsSerializer .validate and BulkEditSerializer._validate_parameters_edit_pdf -- #14083's own `< 0 or >= len(operations)` check is now fully redundant here since PdfEditOperationSerializer.doc already has min_value=0. Removed the redundant second check in both methods. Also split the merged test_edit_pdf_invalid_params subtest: #14083's loop asserted the same "doc index is out of bounds" message for both doc=-1 and doc=2**32, but with min_value=0 in place, -1 is now rejected earlier by the field itself with a different message.
This commit is contained in:
@@ -1769,7 +1769,14 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
self.assertIn(b"valid integer is required", response.content)
|
||||
|
||||
for doc_index in (-1, 2**32):
|
||||
# A negative doc index is rejected by PdfEditOperationSerializer's
|
||||
# own min_value=0 field constraint, before the "doc index is out
|
||||
# of bounds" object-level check (against len(operations)) ever
|
||||
# runs -- hence the different expected message per case.
|
||||
for doc_index, expected_message in (
|
||||
(-1, b"greater than or equal to 0"),
|
||||
(2**32, b"doc index is out of bounds"),
|
||||
):
|
||||
with self.subTest(doc_index=doc_index):
|
||||
response = self.client.post(
|
||||
"/api/documents/edit_pdf/",
|
||||
@@ -1782,7 +1789,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
self.assertIn(b"doc index is out of bounds", response.content)
|
||||
self.assertIn(expected_message, response.content)
|
||||
|
||||
response = self.client.post(
|
||||
"/api/documents/edit_pdf/",
|
||||
|
||||
Reference in New Issue
Block a user