Create port API with invalid value returns 500(Internal Server Error)

Bug #1477829 reported by Koichi Miura
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Kevin Benton
Kilo
New
Undecided
Unassigned

Bug Description

I executed "POST /v2.0/ports" with invalid value like a "null" as the parameter "allowed_address_pairs".
Then Neutron Server returned 500(Internal Server Error).

I expected Neutron Server just returns 400(Bad Request).

API Result and Logs are as follows.
[API Result]
stack@ubuntu:~/deg$ curl -g -i -X POST -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" http://192.168.122.99:9696/v2.0/ports -d "{\"port\":{\"network_id\":\"7da5015b-4e6a-4c9f-af47-42467a4a34c5\",\"allowed_address_pairs\":null}}" ; echo
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Content-Length: 150
X-Openstack-Request-Id: req-f44e7756-dd17-42c9-81e2-1c38e60a748e
Date: Thu, 23 Jul 2015 09:35:26 GMT

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

[Neutron Server Log]
2015-07-23 18:35:26.373 DEBUG neutron.api.v2.base [req-f44e7756-dd17-42c9-81e2-1c38e60a748e demo 0522fc19a56b4d7ca32a9140d3d36a08] Request body: {u'port': {u'network_id': u'7da5015b-4e6a-4c9f-af47-42467a4a34c5', u'allowed_address_pairs': None}} from (pid=24318) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:606
2015-07-23 18:35:26.376 ERROR neutron.api.v2.resource [req-f44e7756-dd17-42c9-81e2-1c38e60a748e demo 0522fc19a56b4d7ca32a9140d3d36a08] create failed
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource Traceback (most recent call last):
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/resource.py", line 83, in resource
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource result = method(request=request, **args)
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 146, in wrapper
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource ectxt.value = e.inner_exc
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 119, in __exit__
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 136, in wrapper
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 396, in create
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource allow_bulk=self._allow_bulk)
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 664, in prepare_request_body
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource attr_vals['validate'][rule])
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/extensions/allowedaddresspairs.py", line 52, in _validate_allowed_address_pairs
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource if len(address_pairs) > cfg.CONF.max_allowed_address_pair:
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource TypeError: object of type 'NoneType' has no len()
2015-07-23 18:35:26.376 TRACE neutron.api.v2.resource

Changed in neutron:
assignee: nobody → Koichi Miura (miura-koichi)
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/218472

Changed in neutron:
assignee: Koichi Miura (miura-koichi) → Kevin Benton (kevinbenton)
status: New → In Progress
Revision history for this message
Kevin Benton (kevinbenton) wrote :

Hi, sorry I took over this bug. I ran into this locally and wrote up a patch and when I went to file the bug I found this was already filed.

Changed in neutron:
assignee: Kevin Benton (kevinbenton) → Sean Dague (sdague)
Changed in neutron:
assignee: Sean Dague (sdague) → Kevin Benton (kevinbenton)
Changed in neutron:
assignee: Kevin Benton (kevinbenton) → Armando Migliaccio (armando-migliaccio)
Changed in neutron:
milestone: none → liberty-rc1
assignee: Armando Migliaccio (armando-migliaccio) → Kevin Benton (kevinbenton)
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/218472
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=8c3cb79aa54b0ffcdc840c7e95ab809835d05001
Submitter: Jenkins
Branch: master

commit 8c3cb79aa54b0ffcdc840c7e95ab809835d05001
Author: Kevin Benton <email address hidden>
Date: Thu Aug 27 22:12:48 2015 -0700

    Better message on allowed address pairs error

    Neutron was throwing a 500 error when a non-iterable was passed
    into allowed address pairs. This patch just catches that and
    converts it into a regular badrequest message.

    Closes-Bug: #1477829
    Change-Id: I3c6f55df4912c7a9480fa097988f910b254572fd
    Signed-off-by: Kevin Benton <email address hidden>

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (feature/pecan)

Fix proposed to branch: feature/pecan
Review: https://review.openstack.org/224334

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: feature/pecan
Review: https://review.openstack.org/224357

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (feature/pecan)
Download full text (73.6 KiB)

Reviewed: https://review.openstack.org/224357
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=fdc3431ccd219accf6a795079d9b67b8656eed8e
Submitter: Jenkins
Branch: feature/pecan

commit fe236bdaadb949661a0bfb9b62ddbe432b4cf5f1
Author: Miguel Angel Ajo <email address hidden>
Date: Thu Sep 3 15:40:12 2015 +0200

    No network devices on network attached qos policies

    Network devices, like internal router legs, or dhcp ports
    should not be affected by bandwidth limiting rules.

    This patch disables application of network attached policies
    to network/neutron owned ports.

    Closes-bug: #1486039
    DocImpact

    Change-Id: I75d80227f1e6c4b3f5fa7762b8dc3b0c0f1abd46

commit db4a06f7caa20a4c7879b58b20e95b223ed8eeaf
Author: Ken'ichi Ohmichi <email address hidden>
Date: Wed Sep 16 10:04:32 2015 +0000

    Use tempest-lib's token_client

    Now tempest-lib provides token_client modules as library and the
    interface is stable. So neutron repogitory doesn't need to contain
    these modules.
    This patch makes neutron use tempest-lib's token_client and removes
    the own modules for the maintenance.

    Change-Id: Ieff7eb003f6e8257d83368dbc80e332aa66a156c

commit 78aed58edbe6eb8a71339c7add491fe9de9a0546
Author: Jakub Libosvar <email address hidden>
Date: Thu Aug 13 09:08:20 2015 +0000

    Fix establishing UDP connection

    Previously, in establish_connection() for UDP protocol data were sent
    but never read on peer socket. That lead to successful read on peer side
    if this connection was filtered. Having constant testing string masked
    this issue as we can't distinguish to which test of connectivity data
    belong.

    This patch makes unique data string per test_connectivity() and
    also makes establish_connection() to create an ASSURED entry in
    conntrack table. Finally, in last test after firewall filter was
    removed, connection is re-established in order to avoid troubles with
    terminated processes or TCP continuing sending packets which weren't
    successfully delivered.

    Closes-Bug: 1478847
    Change-Id: I2920d587d8df8d96dc1c752c28f48ba495f3cf0f

commit e6292fcdd6262434a7b713ad8802db6bc8a6d3dc
Author: YAMAMOTO Takashi <email address hidden>
Date: Wed Sep 16 13:20:51 2015 +0900

    ovsdb: Fix a few docstring

    Change-Id: I53e1e21655b28fe5da60e58aeeb7cbbd103ae014

commit c22949a4449d96a67caa616290cf76b67b182917
Author: fumihiko kakuma <email address hidden>
Date: Wed Sep 16 11:52:59 2015 +0900

    Remove requirements.txt for the ofagent mechanism driver

    It is no longer used.

    Related-Blueprint: core-vendor-decomposition
    https://blueprints.launchpad.net/neutron/+spec/core-vendor-decomposition

    Change-Id: Ib31fb3febf8968e50d86dd66e1e6e1ea2313f8ac

commit d1d4de19d85f961d388c91e70f31b3bafec418c5
Author: Kevin Benton <email address hidden>
Date: Thu Sep 3 20:25:57 2015 -0700

    Always return iterables in L3 get_candidates

    The caller of this function expects iterables.

    Closes-Bug: #1494996
    Change-Id: I3d103e63f4e127a77268502415c0ddb0d804b54a

commit 1ad6ac448067306...

tags: added: in-feature-pecan
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on neutron (feature/pecan)

Change abandoned by Doug Wiegley (<email address hidden>) on branch: feature/pecan
Review: https://review.openstack.org/224334

Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: liberty-rc1 → 7.0.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/297041

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/kilo)

Reviewed: https://review.openstack.org/297041
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=a58e66714e28720b4b0f368afc023421f491735c
Submitter: Jenkins
Branch: stable/kilo

commit a58e66714e28720b4b0f368afc023421f491735c
Author: Kevin Benton <email address hidden>
Date: Thu Aug 27 22:12:48 2015 -0700

    Better message on allowed address pairs error

    Neutron was throwing a 500 error when a non-iterable was passed
    into allowed address pairs. This patch just catches that and
    converts it into a regular badrequest message.

    Closes-Bug: #1477829
    Change-Id: I3c6f55df4912c7a9480fa097988f910b254572fd
    Signed-off-by: Kevin Benton <email address hidden>
    (cherry picked from commit 8c3cb79aa54b0ffcdc840c7e95ab809835d05001)

tags: added: in-stable-kilo
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/neutron 2015.1.4

This issue was fixed in the openstack/neutron 2015.1.4 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

This issue was fixed in the openstack/neutron 2015.1.4 release.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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