Cannot create image: Json Circular reference detected
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance |
Fix Released
|
Critical
|
Jay Pipes |
Bug Description
When trying to play around with 'glance' and create an image I am keep getting a :
Traceback (most recent call last):
File "/usr/local/
result = self.applicatio
File "/usr/local/
return resp(environ, start_response)
File "/usr/lib/
response = self.app(environ, start_response)
File "/usr/local/
return resp(environ, start_response)
File "/usr/local/
resp = self.call_func(req, *args, **self.kwargs)
File "/usr/local/
return self.func(req, *args, **kwargs)
File "/home/
return self._serialize
File "/home/
return serializer.
File "/home/
return self._methods.
File "/home/
return json.dumps(data, default=sanitizer)
File "/usr/lib/
**kw)
File "/usr/lib/
chunks = list(self.
File "/usr/lib/
for chunk in self._iterencod
File "/usr/lib/
for chunk in self._iterencod
File "/usr/lib/
for chunk in self._iterencod
File "/usr/lib/
raise ValueError(
ValueError: Circular reference detected
Something along those lines would fix it : (since we were trying to serialize a non serializable object)
=== modified file 'glance/
--- glance/
+++ glance/
@@ -108,6 +108,9 @@
try:
return dict(image=
+ n = {'image' : dict(new_image)}
+ del(n['
+ return n
except exception.
return exc.HTTPConflict()
except exception.Invalid:
Let me know if that seems to be good enough and I'll do a merge request..
Changed in glance: | |
status: | Confirmed → Fix Committed |
Changed in glance: | |
milestone: | none → 0.1.7 |
status: | Fix Committed → Fix Released |
More background on that, this is my test script:
,---- HTTPConnection( "chmoutest" , 9191) keys(): image_metadata) image_metadata)
| import httplib
| import json
| cnx = httplib.
| image_metadata = {'id': 2,
| 'name': 'fake image #2',
| 'is_public': True,
| 'image_type': 'kernel',
| 'status': 'available',
| 'properties': []}
| if 'image' not in image_metadata.
| image_metadata = dict(image=
|
| body = json.dumps(
| print json.loads(body)
|
| cnx.request("POST", "/images", body)
|
| res = cnx.getresponse()
| print res.status
| print res.read()
`----
this is the object trying to get serialized without my patch :
,---- parallax. db.sqlalchemy. models. Image object at 0x1d50d10>}
| {'image': <glance.
`----
when this should be probably this object ( the n = {'image' : dict(new_image)} part ):
,---- state': <sqlalchemy. orm.state. InstanceState object at 0x1f54e10>, datetime( 2010, 12, 9, 10, 22, 48, 311160),
| {'image': {'_sa_instance_
| 'created_at': datetime.
| 'deleted': False,
| 'deleted_at': None,
| 'id': 2,
| 'image_type': u'kernel',
| 'is_public': True,
| 'name': u'fake image #2',
| 'properties': [],
| 'status': u'available',
| 'updated_at': None}}
`----
maybe I am not using it properly ?
I have ended doing the insert directly in the DB without the API :
http:// c0403512. cdn.cloudfiles. rackspacecloud. com/glance_ create_ data_noauth. py