Safer handling inside of OperationLogMIddleware when object is unserializable

Bug #1784438 reported by Eddie Ramirez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Medium
Eddie Ramirez

Bug Description

function _get_request_param() in https://github.com/openstack/horizon/blob/master/horizon/middleware/operation_log.py#L169-L190 returns a json dump of params that is not always serializable.

I'm proposing a better handling of the return statement when the object "params" is unserializable.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
assignee: nobody → Eddie Ramirez (ediardo)
status: New → In Progress
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Could you explain some example of unserializable case? I would like to know more detail on when it happens.

Revision history for this message
Eddie Ramirez (ediardo) wrote :

Akihiro:

Attaching the log output below. The issue was identified as the horizon operation logger failed to json serialize the murano request.

2017-06-14 16:19:06,811 [ERROR] django.request: Internal Server Error: /murano/packages/upload
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 223, in get_response
    response = middleware_method(request, response)
  File "/usr/lib/python2.7/site-packages/horizon/middleware/operation_log.py", line 70, in process_response
    params = self._get_parameters_from_request(request)
  File "/usr/lib/python2.7/site-packages/horizon/middleware/operation_log.py", line 138, in _get_parameters_from_request
    'param': self._get_request_param(request),
  File "/usr/lib/python2.7/site-packages/horizon/middleware/operation_log.py", line 162, in _get_request_param
    return json.dumps(params, ensure_ascii=False)
  File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")

Akihiro Motoki (amotoki)
Changed in horizon:
importance: Undecided → Medium
milestone: none → rocky-rc2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/587185
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=27f619cf9b82d720ec83f72e02a4821606394829
Submitter: Zuul
Branch: master

commit 27f619cf9b82d720ec83f72e02a4821606394829
Author: Eddie Ramirez <email address hidden>
Date: Mon Jul 30 11:03:02 2018 -0700

    Safer handling of return statement inside of OperationLogMiddleware

    Enclosing return statement in a try block. If object is unserializable
    then return a message.

    Change-Id: I184f4b10a419037d3ed770fbec42c262f03a89f2
    Closes-bug: #1784438

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.openstack.org/592090

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

Reviewed: https://review.openstack.org/592090
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=ef21e65fac85b46a146e42fcebea61f6bb948092
Submitter: Zuul
Branch: stable/rocky

commit ef21e65fac85b46a146e42fcebea61f6bb948092
Author: Eddie Ramirez <email address hidden>
Date: Mon Jul 30 11:03:02 2018 -0700

    Safer handling of return statement inside of OperationLogMiddleware

    Enclosing return statement in a try block. If object is unserializable
    then return a message.

    Change-Id: I184f4b10a419037d3ed770fbec42c262f03a89f2
    Closes-bug: #1784438
    (cherry picked from commit 27f619cf9b82d720ec83f72e02a4821606394829)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 14.0.0.0rc2

This issue was fixed in the openstack/horizon 14.0.0.0rc2 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 15.0.0.0b1

This issue was fixed in the openstack/horizon 15.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.