Comment 1 for bug 1721608

Revision history for this message
Ellen Batbouta (ellen-batbouta) wrote :

Stan Lagun has provided us with a fix for this. Many thanks to Stan for his help. Here is Stan's mail:

the problem is here: https://github.com/openstack/murano-dashboard/blob/master/muranodashboard/dynamic_ui/helpers.py#L107-L126
If the function input happens to be a dictionary, with one of the values set to a list of ObjectID (i.e. the objects returned by the `ref` function), it won't process them but rather leave them as is. I'm not sure why it resulted in circular references error rather than in `object is not serializable`, but probably this is due to another/buggy json serializer was used. Anyway, with the fix, I was able to create the application.
Here is how the function is supposed to be:

def insert_hidden_ids(application):
    def wrap(k, v):
        if k == '?' and isinstance(v, dict) and not isinstance(
                v.get('id'), ObjectID):
            v['id'] = str(uuid.uuid4())
            return k, v
        return rec(k), rec(v)

    def rec(val):
        if isinstance(val, dict):
            return dict(wrap(k, v) for k, v in six.iteritems(val))
        elif isinstance(val, list):
            return [rec(v) for v in val]
        elif isinstance(val, ObjectID):
            return val.object_id
        else:
            return val

    return rec(application)

Please submit this fix to upstream

Best regards,
Stan