[openstack-dev] [api-wg][api][neutron] How to handle invalid query parameters

Hongbin Lu hongbin.lu at huawei.com
Wed Mar 7 21:09:03 UTC 2018

Hi all,

This is a follow-up for the discussion in Dublin PTG about how Neutron API server should handle invalid query parameter [1]. According to the feedback, I sent this ML to seek advice from API-WG in this regards.

As a brief recap, we were discussing how Neutron API server should behave if invalid query parameters were inputted. Per my understanding, the general consensus is to make Neutron API server behave consistently with other OpenStack projects. The question for API-WG is if there is any guideline to clarify how OpenStack projects should handle invalid query parameters. Query parameters are various across different projects but it seems most projects support these four categories of query parameters: sorting, pagination, filtering, and fields selection. I saw API-WG provided a guideline to define how to handle valid parameters of these categories [2], but it doesn't seem to define how to handle invalid parameters.

I wonder if API-WG could clarify it. For example, if users provide an invalid filter on listing the resources, should the API server ignore the invalid filter and return a successful response? Or it should return an error response? Below is a list of specific scenarios and examples to consider:

1. Invalid sorting. For example:

  GET "/v2.0/networks?sort_dir=desc&sort_key=<invalid_field>"
  GET "/v2.0/networks?sort_dir=<invalid_sort_dir>&sort_key=xxx"

2. Invalid pagination. For example:

  GET "/v2.0/networks?limit=<invalid_limit>&marker=xxx"
  GET "/v2.0/networks?limit=1&marker=<invalid_marker>"

3. Invalid filter. For example:

GET "/v2.0/networks?<invalid_field>=xxx"
GET "/v2.0/networks?xxx=<invalid_value>"

4. Invalid field. For example:

  GET "/v2.0/networks?fields=<invalid_field>"

Best regards,

[1] https://bugs.launchpad.net/neutron/+bug/1749820
[2] https://specs.openstack.org/openstack/api-wg/guidelines/pagination_filter_sort.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20180307/ff180923/attachment.html>

More information about the OpenStack-dev mailing list