ValueError: Circular reference detected

Hi!

I've just made a migratin from plone 4.3.7 to 5.0.8. All gone well but now i have an issue.

When i go to content_folder, i have this Traceback:

Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.content.browser.vocabulary, line 248, in call
Module plone.app.content.utils, line 23, in json_dumps
Module json, line 251, in dumps
Module json.encoder, line 207, in encode
Module json.encoder, line 270, in iterencode
ValueError: Circular reference detected
2018-01-19 08:57:21 ERROR Zope.SiteErrorLog 1516348641.710.523847252744 http://localhost:8080/Geomorphology/@@getVocabulary
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.content.browser.vocabulary, line 248, in call
Module plone.app.content.utils, line 23, in json_dumps
Module json, line 251, in dumps
Module json.encoder, line 207, in encode
Module json.encoder, line 270, in iterencode
ValueError: Circular reference detected

How can i solve this? any ideas?

I have seen this same error message a few days ago in this list. I suggest you search for the corresponding discussion and join in.
As far as I understand, the issue has not yet been resolved. But joining forces may speed up the finding of a solution.

Obviously a bug in the code that aggregates the vocabulary data which then contains a circular reference which can not be serialized to JSON. How is this reproducible?

-aj

unfortunately there is not enough in the trace for me to guess. Plone code would have to be modified for that.

If you want you can try that.

go to your buildout-cache/eggs/plone.app.content-????.egg/plone/app/content/browser directory (???? is replaced with the current version for your Plone installation)
save the vocabulary.py file with something like mv vocabulary.py vocabulary.py.ori, then copy back with cp vocabulary.py.ori vocabulary.py.
Then patch vocabulary.py with this:

--- vocabulary.py.ori	2017-06-09 19:17:45.000000000 +0200
+++ vocabulary.py	2018-01-23 11:17:13.983716225 +0100
@@ -243,10 +243,15 @@
         if total == 0:
             total = len(items)
 
-        return json_dumps({
-            'results': items,
-            'total': total
-        })
+        try:
+            r = json_dumps({
+                'results': items,
+                'total': total
+            })
+        except Exception as e:
+            print("error with vocabulary: " + str(vocabulary) + ", items:" + str(items))
+            raise e
+        return r
 
     def parsed_query(self, ):
         query = _parseJSON(self.request.get('query', ''))

if you are using an Unix like computer you can use the GNU utility 'patch'. Save the diff to a file, for exemple 'mypatch.dif'
then

patch vocabulary.py <mypatch.dif

With Windows GNU patch can also be used but you have to download it from an appropriate GNU mirror.

If you can't do any of this you can try to add the code manually to the file with an editor (removing the '+' at the beginning of the added lines that are intended for the 'patch' utility, the line beginning by '-' have to be deleted), warning it's difficult to do it right for a non Python programmer because with Python spaces characters are important.

Then restart your Plone instance. If it does not start you did not patch the file correctly, try to correct it. If yes, try to reproduce the problem. Before the trace there should be more info, please post it here.

If you need more info before you start, don't hesitate to ask.

1 Like

HI!

I post here the trace back and the other output:

error with vocabulary: <plone.app.vocabularies.catalog.CatalogVocabulary object at 0x7fd5c6b16d50>

, items:[{u'getURL': 'http://localhost:8080/Plone3/media-folder/2013', u'total_comments': 0, u'Title': '2013', u'exclude_from_nav': False, u'Type': u'Folder', u'id': '2013', u'last_comment_date': None, u'UID': u'004c79da7c344d51a690f8bf5379a085', u'is_folderish': True, u'ExpirationDate': 'None', u'ModificationDate': '2013-06-13T06:19:07+01:00', u'review_state': 'private', u'location': '', u'EffectiveDate': '2013-03-28T19:10:37+01:00', u'portal_type': 'Folder', u'path': '/media-folder/2013', u'getObjSize': '1 KB', u'Description': 'Media news in the year 2013', u'collective_geo_styles': {'marker_image_size': 0.9, 'map_height': None, 'map_width': None, 'use_custom_styles': False, 'map_viewlet_position': 'plone.abovecontentbody', 'marker_image': u'string:${portal_url}/img/marker.png', 'linecolor': u'ff00003c', 'linewidth': 2.0, 'display_properties': ['Title', 'Description'], 'polygoncolor': u'ff00003c'}, u'Creator': 'cinzia', u'getIcon': False, u'SFAllDay': False, u'CreationDate': '2018-01-30T14:11:34+01:00', u'Subject': ()}]

2018-01-30 14:57:34 ERROR Zope.SiteErrorLog 1517320654.720.870310205089 http://localhost:8080/Plone3/@@getVocabulary
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.app.content.browser.vocabulary, line 253, in call
ValueError: Circular reference detected

How should i procede?

Ugh. Obviously the problem comes from collective_geo_styles, so it comes from the geomancy add-on. There is serious magic here, I need to think about it as I have forgotten a bit about your problem. Possibly the only way to reproduce the problem would be to install geo in a 4.3 and migrate it to 5. Not fast and easy task. Anyway, you managed to patch the code all right that's a good point for you.

1 Like

As mentioned in a previous reply, you should search for the other discussion for the same issue. There, you would learn, that the circular reference comes from portal_catalog. You do not see it in your output because your items are in fact so called "catalog brains"; they have a specialized repr which does not show the hidden catalog reference.

At the moment, I suppose that plone.app. content.vocabulary does not handle the "catalog brain" case correctly: it should cut of the portal_catalog reference when it constructs its "item" from a "brain".

Resoved the problem

I went in portal_catalog Metadata and i removed collective_geo_styles.
After that all worked. I don't know if it's the correct way but works :slight_smile: