Circular reference error when UI contains a list of Object Ids
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Murano |
Fix Released
|
Undecided
|
Gerry Buteau |
Bug Description
In the ui yaml file, I have this:
Templates:
sharedIpTemplate:
?:
type: io.murano.SharedIp
assignFloat
sharedIpAddress: ref(sharedIpTem
.
.
.
Application:
sharedIpAddre
servers:
?:
type: io.murano.
numItems: $.appConfigurat
provider:
?:
type: io.murano.
template:
?:
type: io.murano.
flavor: $.instanceConfi
.
.
.
sharedIps: repeat(
When I try to add my package (that contains the above code) to an environment, it fails with
this error (found in horizon log file);
Wed Oct 04 13:33:59.961846 2017] [:error] [pid 15]
[Wed Oct 04 13:33:59.961853 2017] [:error] [pid 15] {"updated": "2017-10-
[Wed Oct 04 13:33:59.961863 2017] [:error] [pid 15]
[Wed Oct 04 13:33:59.962159 2017] [:error] [pid 15] DEBUG:muranodas
[Wed Oct 04 13:33:59.962414 2017] [:error] [pid 15] DEBUG:muranodas
[Wed Oct 04 13:34:00.008962 2017] [:error] [pid 15] ERROR:muranodas
[Wed Oct 04 13:34:00.009004 2017] [:error] [pid 15] Traceback (most recent call last):
[Wed Oct 04 13:34:00.009015 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009023 2017] [:error] [pid 15] self.request, environment_id, attributes)
[Wed Oct 04 13:34:00.009031 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009039 2017] [:error] [pid 15] session_
[Wed Oct 04 13:34:00.009046 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009054 2017] [:error] [pid 15] return f(*args, **kwargs)
[Wed Oct 04 13:34:00.009062 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009069 2017] [:error] [pid 15] headers=headers, return_raw=True)
[Wed Oct 04 13:34:00.009076 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009083 2017] [:error] [pid 15] data=data, headers=headers)
[Wed Oct 04 13:34:00.009090 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009098 2017] [:error] [pid 15] kwargs['data'] = jsonutils.
[Wed Oct 04 13:34:00.009105 2017] [:error] [pid 15] File "/var/lib/
[Wed Oct 04 13:34:00.009112 2017] [:error] [pid 15] return json.dumps(obj, default=default, **kwargs)
[Wed Oct 04 13:34:00.009119 2017] [:error] [pid 15] File "/usr/lib64/
[Wed Oct 04 13:34:00.009136 2017] [:error] [pid 15] sort_keys=
[Wed Oct 04 13:34:00.009143 2017] [:error] [pid 15] File "/usr/lib64/
[Wed Oct 04 13:34:00.009150 2017] [:error] [pid 15] chunks = self.iterencode(o, _one_shot=True)
[Wed Oct 04 13:34:00.009157 2017] [:error] [pid 15] File "/usr/lib64/
[Wed Oct 04 13:34:00.009164 2017] [:error] [pid 15] return _iterencode(o, 0)
[Wed Oct 04 13:34:00.009171 2017] [:error] [pid 15] ValueError: Circular reference detected
[Wed Oct 04 13:34:00.009557 2017] [:error] [pid 15] Recoverable error: Circular reference detected
[Wed Oct 04 13:34:05.349043 2017] [:error] [pid 16] DEBUG:muranodas
[Wed Oct 04 13:34:05.349225 2017] [:error] [pid 16] DEBUG:muranodas
Changed in murano: | |
assignee: | nobody → Gerry Buteau (gerry.buteau) |
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 ):
v.get( 'id'), ObjectID):
def wrap(k, v):
if k == '?' and isinstance(v, dict) and not isinstance(
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