Skip to content

Commit 3160f55

Browse files
committed
Added code to catch a form error regularly caused by form spam and return a failure instead of triggering a server 500.
- Legacy-Id: 16728
1 parent 81bc175 commit 3160f55

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ietf/doc/fields.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def clean(self, value):
8989
value = super(SearchableDocumentsField, self).clean(value)
9090
pks = self.parse_select2_value(value)
9191

92-
objs = self.model.objects.filter(pk__in=pks)
92+
try:
93+
objs = self.model.objects.filter(pk__in=pks)
94+
except ValueError as e:
95+
raise forms.ValidationError("Unexpected field value; %s" % e)
9396

9497
found_pks = [ str(o.pk) for o in objs ]
9598
failed_pks = [ x for x in pks if x not in found_pks ]

0 commit comments

Comments
 (0)