Filter arguments validation #695
Labels
complexity: low
Requires minimal effort to implement
status: accepted
This issue has been accepted for implementation
type: feature
Introduction of new functionality to the application
Uh oh!
There was an error while loading. Please reload this page.
pynetbox version
v7.5.0
NetBox version
v.4.3.1
Feature type
New functionality
Proposed functionality
Validation of the filter Endpoint arguments before sending request to NetBox, using the openapi description provided by NetBox itself, which is supposed to contain all the supported filter expressions.
A first version of this implementation is here : https://github.com/m0nkeyc0de/pynetbox/tree/filter-validation
pynetbox
is conserved. The feature must be activated with thestrict_filter
kwarg.openapi
method that fetches the API specification was already implemented. I modified it to avoid repeated calls for always the same data on the NetBox API._validate_openapi_parameters
which does the validation work is added in theEndpoint
class and is called within thefilter()
method.What could be improved:
strict_filter
is not enabledopenapi
specifications nicelyUse case
As described in #693 the actual behavior of NetBox is to return the entire database table if an error is made in the filter. There is no indication that the API user made an error. You could get 4321 results because your filter matches all the objects but you also could get 4321 objects because you mistyped a filter without noticing it right away.
This would improve the quality of life for NetBox API users and reduce the risk of making invisible mistakes.
External dependencies
No additional external python dependencies are needed.
The text was updated successfully, but these errors were encountered: