Create/Update port responds 500 to the request with invalid "security_groups"

Bug #1477921 reported by Kengo Hobo
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Kengo Hobo

Bug Description

When I request "POST /v2.0/ports/​" and "PUT /v2.0/ports/​{port_id}​" with an invalid value(ex.integer) as "security_groups",
Neutron Server responds 500(Internal Server Error).

It should respond 400 error not 500 error.

API Result and Logs are as follows.
[API Result]
"POST /v2.0/ports/​"
stack@ubuntu:~$ curl -gi -X POST http://192.168.122.99:9696/v2.0/ports -H "X-Auth-Token:${TOKEN}" -d '{"port":{"security_groups":90,"network_id":"77e2f811-96
a5-48d2-bd85-132e4f44bcb4"}}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Content-Length: 150
X-Openstack-Request-Id: req-b1e6de3d-8cd0-4015-be65-141126e7c807
Date: Fri, 24 Jul 2015 09:06:07 GMT

{"NeutronError": {"message": "Request Failed: internal server error while processing your request.", "type": "HTTPInternalServerError", "detail": ""}}

"PUT /v2.0/ports/​{port_id}​"
stack@ubuntu:~$ curl -gi -X PUT http://192.168.122.99:9696/v2.0/ports/f95f74ff-1ede-483b-9386-c51f470500fe -H "X-Auth-Token:${TOKEN}" -d '{"port":{"security_groups":90}}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Content-Length: 150
X-Openstack-Request-Id: req-4815865b-9631-4812-9424-3b73c997e56f
Date: Fri, 24 Jul 2015 08:46:51 GMT

{"NeutronError": {"message": "Request Failed: internal server error while processing your request.", "type": "HTTPInternalServerError", "detail": ""}}

[Neutron Server Log]
2015-07-24 17:46:41.947 DEBUG neutron.api.v2.base req-4f4adaa0-3952-4a0f-a450-7b3594c5a11e demo 0522fc19a56b4d7ca32a9140d3d36a08 Request body: {u'port': {u'security_groups': 3}}from (pid=24319) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:606
2015-07-24 17:46:41.949 ERROR neutron.api.v2.resource req-4f4adaa0-3952-4a0f-a450-7b3594c5a11e demo 0522fc19a56b4d7ca32a9140d3d36a08 update failed
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource Traceback (most recent call last):
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource result = method(request=request, **args)
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource ectxt.value = e.inner_exc
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in __exit__
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 525, in update
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource allow_bulk=self._allow_bulk)
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 658, in prepare_request_body
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource res_dict[attr] = attr_vals['convert_to'](res_dict[attr])
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/extensions/securitygroup.py", line 177, in convert_to_uuid_list_or_none
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource for sg_id in value_list:
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource TypeError: 'int' object is not iterable
2015-07-24 17:46:41.949 TRACE neutron.api.v2.resource
2015-07-24 17:46:41.955 INFO neutron.wsgi req-4f4adaa0-3952-4a0f-a450-7b3594c5a11e demo 0522fc19a56b4d7ca32a9140d3d36a08192.168.122.99 - - [24/Jul/2015 17:46:41] "PUT /v2.0/ports/f95f74ff-1ede-483b-9386-c51f470500fe HTTP/1.1" 500 359 0.027116

Kengo Hobo (hobo-kengo)
Changed in neutron:
assignee: nobody → Kengo Hobo (hobo-kengo)
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

This bug is > 172 days without activity. We are unsetting assignee and milestone and setting status to Incomplete in order to allow its expiry in 60 days.

If the bug is still valid, then update the bug status.

Changed in neutron:
assignee: Kengo Hobo (hobo-kengo) → nobody
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
Revision history for this message
Kengo Hobo (hobo-kengo) wrote :

I want to restore this bug report because the bug is still valid.

ubuntu@test:/opt/stack/neutron$ curl -si -X PUT -H "Content-type: application/json" http://172.16.1.31:9696/v2.0/ports/3d207469-06a2-488f-9216-b2ec1bcae915 -H "X-AUTH-TOKEN:${TOKEN}" -d '{"port":{"security_groups":true}}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 150
X-Openstack-Request-Id: req-57b78177-1c4f-405a-810d-fab77ca5d102
Date: Mon, 22 Aug 2016 02:41:20 GMT

{"NeutronError": {"message": "Request Failed: internal server error while processing your request.", "type": "HTTPInternalServerError", "detail": ""}}

Changed in neutron:
status: Expired → New
assignee: nobody → Kengo Hobo (hobo-kengo)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/358468

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/358468
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=4f4d9ad3d33da85df2530347617b9dbc33543e54
Submitter: Jenkins
Branch: master

commit 4f4d9ad3d33da85df2530347617b9dbc33543e54
Author: hobo.kengo <email address hidden>
Date: Mon Aug 22 03:21:53 2016 +0000

    Add validation for security_groups parameter in Port

    Currently, we check whether specified value in list
    matches with UUID format or not.
    However, we don't check whether data type of specified value of
    security_groups key is list in the first place.
    This patch adds check above.

    Change-Id: If027df3ff34b219e4a043934b9461ac0fcb40156
    Closes-Bug: #1477921

Changed in neutron:
status: In Progress → Fix Released
Akihiro Motoki (amotoki)
Changed in neutron:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 11.0.0.0b1

This issue was fixed in the openstack/neutron 11.0.0.0b1 development milestone.

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.