Skip to content

Commit

Permalink
bug-1928808: fix _report_type validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
willkg committed Nov 2, 2024
1 parent 8bf7b51 commit fb7ea10
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion webapp/crashstats/topcrashers/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit fb7ea10

Please sign in to comment.