ContextView instances don't get serialized into JSON properly

Bug #1867899 reported by Renat Akhmerov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
Critical
Renat Akhmerov

Bug Description

If YAQL data conversion is disabled then YAQL may return an instance of ContextView class. It happens for the expression <% $ %>. It turns out though that instances of this class are not saved into the database properly because JSON serialization doesn't work for them. Instead of a normal dictionary JSON representation we always get "{}" (empty dict).

Changed in mistral:
milestone: none → ussuri-3
assignee: nobody → Renat Akhmerov (rakhmerov)
importance: Undecided → Critical
Changed in mistral:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.opendev.org/713174
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=019cffb3abd467d75e4f038e889f2a9b4bd58b34
Submitter: Zuul
Branch: master

commit 019cffb3abd467d75e4f038e889f2a9b4bd58b34
Author: Renat Akhmerov <email address hidden>
Date: Fri Mar 13 16:55:25 2020 +0700

    Fix ContextView JSON serialization

    * With disabled YAQL data output conversion, YAQL may return
      instances of ContextView which can't be properly saved into
      DB. This happens because Mistral serialization code doesn't
      turn on JSON conversion of custom objects, and they are just
      ignored by the "json" lib when it encounters them.
    * Fixed how Mistral serializes context for Javascript evaluation
      to address the same problem.
    * Implemented __repr__ method of ContextView.
    * Removed logging of "data_context" from YAQL evaluation because
      previously it was always empty (because the string represetation
      of ContextView was always "{}") and now it may be very big, like
      megabytes, and the log gets populated too fast. It makes sense to
      log YAQL data context only when an error happened. In this case
      it helps to investigate an issue.
    * Added all required unit tests.
    * Fixed the tests for disabled YAQL conversion. In fact, they
      didn't test it properly because data conversion wasn't disabled.

    Closes-Bug: #1867899
    Change-Id: I12b4d0c5f1f49990d8ae09b72f73c0da96254a86

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

Fix proposed to branch: stable/train
Review: https://review.opendev.org/713886

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

Reviewed: https://review.opendev.org/713886
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=241ea888c6993ac045cf12d6b61d4e1a1ff29ad3
Submitter: Zuul
Branch: stable/train

commit 241ea888c6993ac045cf12d6b61d4e1a1ff29ad3
Author: Renat Akhmerov <email address hidden>
Date: Fri Mar 13 16:55:25 2020 +0700

    Fix ContextView JSON serialization

    * With disabled YAQL data output conversion, YAQL may return
      instances of ContextView which can't be properly saved into
      DB. This happens because Mistral serialization code doesn't
      turn on JSON conversion of custom objects, and they are just
      ignored by the "json" lib when it encounters them.
    * Fixed how Mistral serializes context for Javascript evaluation
      to address the same problem.
    * Implemented __repr__ method of ContextView.
    * Removed logging of "data_context" from YAQL evaluation because
      previously it was always empty (because the string represetation
      of ContextView was always "{}") and now it may be very big, like
      megabytes, and the log gets populated too fast. It makes sense to
      log YAQL data context only when an error happened. In this case
      it helps to investigate an issue.
    * Added all required unit tests.
    * Fixed the tests for disabled YAQL conversion. In fact, they
      didn't test it properly because data conversion wasn't disabled.

    Closes-Bug: #1867899
    Change-Id: I12b4d0c5f1f49990d8ae09b72f73c0da96254a86

tags: added: in-stable-train
summary: - ConteView instances don't get serialized into JSON properly
+ ContextView instances don't get serialized into JSON properly
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 10.0.0.0b3

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