500 Error is returned when specifying string that is partial matched to "application/json" as format of HTTP header.

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

Bug Description

Currently, 'get_content_type' method in neutron/wsgi.py checks
specified format by 'in' statement.
Thus, string(e.g. 'application/j') that is partial matched to
'application/json' is returned.

However, we cannot find valid serializer from the format,
and request fails with unexpected error.

request
===========================
ubuntu@neutron-ml2:/opt/stack/neutron$ curl -g -i -X GET http://172.16.1.29:9696/v2.0/networks -H "X-Auth-Token: $TOKEN" -H "Content-type: ppli"
HTTP/1.1 500 Internal Server Error
Content-Length: 114
Content-Type: text/plain; charset=UTF-8
X-Openstack-Request-Id: req-c82ae85b-dbec-49ae-ad1f-d1104c437acd
Date: Fri, 12 Aug 2016 03:18:14 GMT

500 Internal Server Error

The server has either erred or is incapable of performing the requested operation.
=============================

trace in neutron-server
=============================
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors Traceback (most recent call last):
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/oslo_middleware/catch_errors.py", line 38, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors response = req.get_response(self.application)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1299, in send
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors application, catch_exc_info=False)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1263, in call_application
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors app_iter = application(self.environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors resp = self.call_func(req, *args, **self.kwargs)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return self.func(req, *args, **kwargs)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/keystonemiddleware/auth_token/__init__.py", line 331, in
 __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors response = req.get_response(self._app)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1299, in send
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors application, catch_exc_info=False)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1263, in call_application
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors app_iter = application(self.environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return resp(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return resp(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/routes/middleware.py", line 141, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors response = self.app(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return resp(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return resp(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/routes/middleware.py", line 141, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors response = self.app(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return resp(environ, start_response)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors resp = self.call_func(req, *args, **self.kwargs)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors return self.func(req, *args, **kwargs)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors File "/opt/stack/neutron/neutron/api/v2/resource.py", line 97, in resource
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors body = serializer.serialize(result)
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors AttributeError: 'NoneType' object has no attribute 'serialize'
2016-08-12 03:18:14.259 13757 ERROR oslo_middleware.catch_errors
2016-08-12 03:18:14.262 13757 INFO neutron.wsgi [req-c82ae85b-dbec-49ae-ad1f-d1104c437acd b3ec23ec52144d7e96696abef028a5b0 7dbb594bc59546f6b26ad73da253c90a - - -] 172.16.1.29 - - [12/Aug/2016 03:18:14] "GET /v2.0/networks HTTP/1.1" 500 317 0.680435
===============================

Kengo Hobo (hobo-kengo)
Changed in neutron:
assignee: nobody → Kengo Hobo (hobo-kengo)
Kengo Hobo (hobo-kengo)
description: updated
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/354551

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

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

commit e99274397c974666ede9d4f1804210e6152b7238
Author: hobo.kengo <email address hidden>
Date: Fri Aug 12 06:49:53 2016 +0000

    Check content type by completely match instead of partial match

    Currently, 'get_content_type' method in neutron/wsgi.py checks
    specified format by 'in' statement.
    Thus, string(e.g. 'application/j') that is partial matched to
    'application/json' is returned.

    However, we cannot find valid serializer from the format,
    and request fails with unexpected error.

    Change-Id: I75aac0308d0fd0321973c4bda3bc07ca0224e1c1
    Closes-Bug: #1612485

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 9.0.0.0b3

This issue was fixed in the openstack/neutron 9.0.0.0b3 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.