Fix: return a JSON 404 for unmatched API URLs and non-numeric document ids (#14917)

This commit is contained in:
Trenton H authored and GitHub committed 2026-11-30 18:38:51 +00:00
1 parent fca95bc821
commit d1251aaef6
4 files changed
+123

No files matched your search

+8
View File
@@ -1036,6 +1036,14 @@ class DocumentViewSet(
# Bound the IN clauses used for search results and through-table lookups.
selection_data_batch_size = 10_000
def initial(self, request, *args, **kwargs):
super().initial(request, *args, **kwargs)
# Only ASCII digits can be a document id, reject anything else here, before
# any action calls int() on it
pk = kwargs.get("pk")
if pk is not None and not (pk.isascii() and pk.isdigit()):
raise Http404
def _get_selection_data_for_queryset(
self,
queryset: QuerySet[Document],