From fb7ea1005030ab115fea8cf23e07982a82c31955 Mon Sep 17 00:00:00 2001 From: Will Kahn-Greene Date: Sat, 2 Nov 2024 08:49:16 -0400 Subject: [PATCH] bug-1928808: fix _report_type validation This fixes _report_type validation in the TopCrashers form so it doesn't create bad Super Search queries which kick up an HTTP 500. Previously, the form did no useful validation (why even have a form?). Now it enforces that _report_type is one of "any", "hang", or "crash" which are the only three values it should have. If it gets a different value, the form will cause the view to raise an HTTP 400 with an error saying that the _report_type value isn't one of the available choices. --- webapp/crashstats/topcrashers/forms.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/crashstats/topcrashers/forms.py b/webapp/crashstats/topcrashers/forms.py index 80d93f1eab..58d4bf4814 100644 --- a/webapp/crashstats/topcrashers/forms.py +++ b/webapp/crashstats/topcrashers/forms.py @@ -16,4 +16,10 @@ class TopCrashersForm(BaseForm): _facets_size = forms.IntegerField(required=False) _tcbs_mode = forms.CharField(required=False) _range_type = forms.CharField(required=False) - _report_type = forms.CharField(required=False) + + # NOTE(willkg): _report_type choices must match the TopCrashers form options in the + # jinja2 template + _report_type = forms.ChoiceField( + choices=[("any", "any"), ("hang", "hang"), ("crash", "crash")], + required=False, + )