Open
Bug 1343263
Opened 8 years ago
Updated 7 years ago
Use django-filters 'strict' and 'together' features rather than custom parameter validation for every API endpoint
Categories
(Tree Management :: Treeherder: API, defect, P3)
Tree Management
Treeherder: API
Tracking
(Not tracked)
NEW
People
(Reporter: emorley, Unassigned)
References
(Blocks 1 open bug)
Details
Until now we've in many cases been writing our own API validation for each endpoint (eg bug 1311980, or search for `except ValueError` under api/*), which is error prone and results in lots of boilerplate.
django-filters performs its own validation of parameters (eg the value passed to a `NumberFilter()` must be a number), and also offers the ability to say that certain pairs of parameters must all be present or not be present at all (using the `together` option).
We should use it instead of the custom validation where possible.
Points to note:
* Not everything is using django-filters - we should probably switch more over
* django-filters has a `strict` setting, which controls the behaviour when an invalid value is provided. This defaults to "return zero results", but we perhaps want "raise a ValidationError" combined with custom exception handling at the D-R-F layer.
Docs:
https://django-filter.readthedocs.io/en/latest/ref/filterset.html#strict
https://django-filter.readthedocs.io/en/latest/ref/filterset.html#together
| Reporter | ||
Comment 2•7 years ago
|
||
This is a probably tricky bug for someone to work on if not familiar with our APIs, but happy for you to take a look if you are sure?
See bug 1427375 comment 3 for links to source and docs :-)
Flags: needinfo?(emorley)
| Reporter | ||
Updated•7 years ago
|
Priority: P2 → P3
You need to log in
before you can comment on or make changes to this bug.
Description
•