← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1513069] [NEW] allowed_address_pairs validator raises 500 when non-list value is specified from users

 

*** This bug is a duplicate of bug 1477829 ***
    https://bugs.launchpad.net/bugs/1477829

Public bug reported:

allowed_address_pairs validator raises 500 when non-list value is specified from users.
In the following example, a user specified True for allowed_address_pairs by mistake.
In this case, neutron server should return BadRequest (400) instead of InternalServerError (500).

Releases: Kilo, Juno

How to reproduce:
Send {u'port': {u'allowed_address_pairs': True}} for an existing port.

2015-11-02 19:33:37.550 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] No route matched for PUT /ports/58d6d971-0519-4746-8e26-4f51185b92b9.json __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:97
2015-11-02 19:33:37.551 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Matched PUT /ports/58d6d971-0519-4746-8e26-4f51185b92b9.json __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:100
2015-11-02 19:33:37.552 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Route path: '/ports/{id}{.format}', defaults: {'action': u'update', 'controller': <wsgify at 139841913111888 wrapping <function resource at 0x7f2f7b94b050>>} __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:102
2015-11-02 19:33:37.552 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Match dict: {'action': u'update', 'controller': <wsgify at 139841913111888 wrapping <function resource at 0x7f2f7b94b050>>, 'id': u'58d6d971-0519-4746-8e26-4f51185b92b9', 'format': u'json'} __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:103
2015-11-02 19:33:37.553 10988 DEBUG neutron.api.v2.base [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Request body: {u'port': {u'allowed_address_pairs': True}} prepare_request_body /usr/lib/python2.7/dist-packages/neutron/api/v2/base.py:582
2015-11-02 19:33:37.554 10988 ERROR neutron.api.v2.resource [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] update failed
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource Traceback (most recent call last):
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/resource.py", line 87, in resource
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     result = method(request=request, **args)
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/base.py", line 501, in update
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     allow_bulk=self._allow_bulk)
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/base.py", line 637, in prepare_request_body
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     attr_vals['validate'][rule])
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/extensions/allowedaddresspairs.py", line 56, in _validate_allowed_address_pairs
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     if len(address_pairs) > cfg.CONF.max_allowed_address_pair:
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource TypeError: object of type 'bool' has no len()
2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource
2015-11-02 19:33:37.557 10988 INFO neutron.wsgi [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] 192.168.23.61,10.2.101.2 - - [02/Nov/2015 19:33:37] "PUT /v2.0/ports/58d6d971-0519-4746-8e26-4f51185b92b9.json HTTP/1.1" 500 439 0.012048

** Affects: neutron
     Importance: Low
         Status: New


** Tags: low-hanging-fruit

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1513069

Title:
  allowed_address_pairs validator raises 500 when non-list value is
  specified from users

Status in neutron:
  New

Bug description:
  allowed_address_pairs validator raises 500 when non-list value is specified from users.
  In the following example, a user specified True for allowed_address_pairs by mistake.
  In this case, neutron server should return BadRequest (400) instead of InternalServerError (500).

  Releases: Kilo, Juno

  How to reproduce:
  Send {u'port': {u'allowed_address_pairs': True}} for an existing port.

  2015-11-02 19:33:37.550 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] No route matched for PUT /ports/58d6d971-0519-4746-8e26-4f51185b92b9.json __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:97
  2015-11-02 19:33:37.551 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Matched PUT /ports/58d6d971-0519-4746-8e26-4f51185b92b9.json __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:100
  2015-11-02 19:33:37.552 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Route path: '/ports/{id}{.format}', defaults: {'action': u'update', 'controller': <wsgify at 139841913111888 wrapping <function resource at 0x7f2f7b94b050>>} __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:102
  2015-11-02 19:33:37.552 10988 DEBUG routes.middleware [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Match dict: {'action': u'update', 'controller': <wsgify at 139841913111888 wrapping <function resource at 0x7f2f7b94b050>>, 'id': u'58d6d971-0519-4746-8e26-4f51185b92b9', 'format': u'json'} __call__ /usr/lib/python2.7/dist-packages/routes/middleware.py:103
  2015-11-02 19:33:37.553 10988 DEBUG neutron.api.v2.base [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] Request body: {u'port': {u'allowed_address_pairs': True}} prepare_request_body /usr/lib/python2.7/dist-packages/neutron/api/v2/base.py:582
  2015-11-02 19:33:37.554 10988 ERROR neutron.api.v2.resource [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] update failed
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource Traceback (most recent call last):
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/resource.py", line 87, in resource
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     result = method(request=request, **args)
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/base.py", line 501, in update
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     allow_bulk=self._allow_bulk)
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/api/v2/base.py", line 637, in prepare_request_body
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     attr_vals['validate'][rule])
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource   File "/usr/lib/python2.7/dist-packages/neutron/extensions/allowedaddresspairs.py", line 56, in _validate_allowed_address_pairs
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource     if len(address_pairs) > cfg.CONF.max_allowed_address_pair:
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource TypeError: object of type 'bool' has no len()
  2015-11-02 19:33:37.554 10988 TRACE neutron.api.v2.resource
  2015-11-02 19:33:37.557 10988 INFO neutron.wsgi [req-7fbb782d-2537-4184-9e16-49e7d3285947 10dfb42eef5842b886a0c65ea5547175 43bc5337a313424a8e746c1b0074de60] 192.168.23.61,10.2.101.2 - - [02/Nov/2015 19:33:37] "PUT /v2.0/ports/58d6d971-0519-4746-8e26-4f51185b92b9.json HTTP/1.1" 500 439 0.012048

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1513069/+subscriptions


Follow ups