Neutron's endpoint cannot tell the difference between '-' and '_'

Bug #1800915 reported by Hongbin Lu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
New
Low
Hongbin Lu

Bug Description

The current neutron API seems to treat '-' and '_' the same. For example, both "/v2.0/security-groups" and "/v2.0/security_groups" will process by the same controller and succeed. More examples is as below:

$ curl -g -i -X GET http://10.0.2.15:9696/v2.0/security-groups -H "Accept: application/json" -H "X-Auth-Token: $TOKEN"
HTTP/1.1 200 OK

$ curl -g -i -X GET http://10.0.2.15:9696/v2.0/security_groups -H "Accept: application/json" -H "X-Auth-Token: $TOKEN"
HTTP/1.1 200 OK

$ curl -g -i -X GET http://10.0.2.15:9696/v2.0/availability-zones -H "Accept: application/json" -H "X-Auth-Token: $TOKEN"
HTTP/1.1 200 OK

$ curl -g -i -X GET http://10.0.2.15:9696/v2.0/availability_zones -H "Accept: application/json" -H "X-Auth-Token: $TOKEN"
HTTP/1.1 200 OK

IMHO, neutron should be strict between '-' and '_'. For example, the second and third commands above should fail or we should update the API documentation about that.

Tags: api doc
Hongbin Lu (hongbin.lu)
tags: added: api
Changed in neutron:
assignee: nobody → Hongbin Lu (hongbin.lu)
Revision history for this message
Slawek Kaplonski (slaweq) wrote :

IMO this should be only well documented. Changing it in API may cause failures on clients so it should be discoverable as any other API change. I'm not sure if that is worth to do :)

Revision history for this message
Brian Haley (brian-haley) wrote :

I would agree with Slawek, making this change would break backwards-compatibility of the API, documenting it would be better.

zhaobo (zhaobo6)
tags: added: doc
Changed in neutron:
importance: Undecided → Low
Revision history for this message
Brian Haley (brian-haley) wrote :

Just looking at old bugs.

To do this correctly, I think we should go change all the "base_path" strings in the openstacksdk repository, for example:

https://opendev.org/openstack/openstacksdk/src/branch/master/openstack/network/v2/network_segment_range.py

Then change the api-ref docs in the neutron-lib repository.

That way using the client with --debug will show the path corresponding to the api-ref.

As a test I issued a token and ran what 'openstack network segment range list' does both ways and it worked the same:

curl -g -i -X GET http://172.16.0.151:9696/networking/v2.0/network_segment_ranges -H "X-Auth-Token: $token" -verbose
> GET /networking/v2.0/network_segment_ranges HTTP/1.1
"success"

curl -g -i -X GET http://172.16.0.151:9696/networking/v2.0/network-segment-ranges -H "X-Auth-Token: $token" -verbose
"success"

So if anyone wants to pick this up they are welcome to.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.