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

Hongbin Lu hongbin.lu at huawei.com
Wed Mar 7 21:02:26 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

华为技术有限公司 Huawei Technologies Co., Ltd.

This e-mail and its attachments contain confidential information from HUAWEI, which
is intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20180307/38caeca7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5474 bytes
Desc: image001.png
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20180307/38caeca7/attachment.png>

More information about the OpenStack-dev mailing list