Exception in creating json response under py35

Bug #1707127 reported by Yujun Zhang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.middleware
Fix Released
Undecided
Yujun Zhang

Bug Description

Code for testing, https://review.openstack.org/#/c/487454/1

    def test_json_response(self):
        expected_body = json.dumps({'detailed': False, 'reasons': []},
                                   indent=4, sort_keys=True).encode('utf-8')
        self._do_test(expected_body=expected_body,
                      accept='application/json')

Exception raised, http://logs.openstack.org/54/487454/1/check/gate-oslo.middleware-python35/09f1af6/console.html

2017-07-26 14:54:50.922294 | ======================================================================
2017-07-26 14:54:50.922316 | FAIL: oslo_middleware.tests.test_healthcheck.HealthcheckTests.test_json_response
2017-07-26 14:54:50.922325 | tags: worker-1
2017-07-26 14:54:50.922345 | ----------------------------------------------------------------------
2017-07-26 14:54:50.922358 | Traceback (most recent call last):
2017-07-26 14:54:50.922396 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/oslo_middleware/tests/test_healthcheck.py", line 201, in test_json_response
2017-07-26 14:54:50.922411 | accept='application/json')
2017-07-26 14:54:50.923016 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/oslo_middleware/tests/test_healthcheck.py", line 79, in _do_test
2017-07-26 14:54:50.923054 | server_port=server_port)
2017-07-26 14:54:50.923093 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/oslo_middleware/tests/test_healthcheck.py", line 70, in _do_test_request
2017-07-26 14:54:50.923108 | res = req.get_response(self.app)
2017-07-26 14:54:50.923144 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/request.py", line 1316, in send
2017-07-26 14:54:50.923159 | application, catch_exc_info=False)
2017-07-26 14:54:50.923198 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/request.py", line 1280, in call_application
2017-07-26 14:54:50.923217 | app_iter = application(self.environ, start_response)
2017-07-26 14:54:50.923264 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/dec.py", line 131, in __call__
2017-07-26 14:54:50.923293 | resp = self.call_func(req, *args, **self.kwargs)
2017-07-26 14:54:50.923337 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/dec.py", line 196, in call_func
2017-07-26 14:54:50.923351 | return self.func(req, *args, **kwargs)
2017-07-26 14:54:50.923377 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/oslo_middleware/base.py", line 128, in __call__
2017-07-26 14:54:50.923391 | response = self.process_request(req)
2017-07-26 14:54:50.923423 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/dec.py", line 149, in __call__
2017-07-26 14:54:50.923435 | return self.func(req, *args, **kw)
2017-07-26 14:54:50.923466 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/oslo_middleware/healthcheck/__init__.py", line 561, in process_request
2017-07-26 14:54:50.923477 | content_type=content_type)
2017-07-26 14:54:50.923510 | File "/home/jenkins/workspace/gate-oslo.middleware-python35/.tox/py35/lib/python3.5/site-packages/webob/response.py", line 310, in __init__
2017-07-26 14:54:50.923527 | "You cannot set the body to a text value without a "
2017-07-26 14:54:50.923545 | TypeError: You cannot set the body to a text value without a charset

Changed in oslo.middleware:
assignee: nobody → Yujun Zhang (yujunz)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.middleware (master)

Reviewed: https://review.openstack.org/487454
Committed: https://git.openstack.org/cgit/openstack/oslo.middleware/commit/?id=c3c9891ddd60a1e6af61d7ab149f2f5b4a74227d
Submitter: Jenkins
Branch: master

commit c3c9891ddd60a1e6af61d7ab149f2f5b4a74227d
Author: Yujun Zhang <email address hidden>
Date: Wed Jul 26 22:51:23 2017 +0800

    Fix exception in json response under py35

    charset is required when response with body

    Closes-Bug: #1707127
    Change-Id: I9921c67866d252f972954eed5afbc90389e06c3f

Changed in oslo.middleware:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.middleware 3.31.0

This issue was fixed in the openstack/oslo.middleware 3.31.0 release.

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.