plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

RecursionError When Accessing /contents page of a Folder via Volto

Open FarooqAlaulddin opened this issue 2 years ago • 5 comments

Describe the bug I am trying to view the contents page of a folder (lets call it plone-folder) in Volto. the plone-folder contain migrated content-types from plone 4. The plone-folder/contents page works in classic backend without any issues. The view works, however the only issue is when I try to access the /contents page of plone-folder.

<site-address>/plone-folder/contents

This effects:

  • copy/paste into/from the folder within volto
  • Search to link a file within a folder from somewhere else within volto

To Reproduce Steps to reproduce the behavior:

  1. Happens on some migrated folders that contains content-types migrated from Plone 4.
  2. Problem do not appear on Classic Plone 6 Configurations. Contents & View Works.
  3. Problem appear when accessing /contents in Volto. Folder view works.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots

BACKEND CLIENT:

2023-04-11 04:32:58,036 ERROR   [Zope.SiteErrorLog:35][waitress-1] RecursionError: http://localhost:3003/standards- 
documents/corrupt-files/@search
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module plone.rest.service, line 22, in __call__
  Module plone.restapi.services, line 19, in render
  Module plone.restapi.services.search.get, line 10, in reply
  Module plone.restapi.search.handler, line 93, in search
  Module plone.restapi.serializer.catalog, line 60, in __call__
  Module plone.restapi.serializer.summary, line 105, in __call__
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.converters, line 101, in list_converter
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.relationfield, line 21, in relationvalue_converter
 ...
  Module plone.restapi.serializer.summary, line 105, in __call__
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.converters, line 101, in list_converter
  Module plone.restapi.serializer.converters, line 68, in json_compatible
  Module zope.component.hooks, line 135, in adapter_hook
  Module plone.restapi.serializer.relationfield, line 21, in relationvalue_converter
  Module plone.restapi.serializer.summary, line 105, in __call__
RecursionError: maximum recursion depth exceeded while calling a Python object

FRONTEND CLIENT:

Returns: Status Code: 500 Internal Server Error

Request Being Sent From Volto:

  • Turning off metadata_fields returns 200. image

Software (please complete the following information):

  • OS: Any
  • Browser: Any
  • Volto Version: Volto 16.6.0
  • Plone Version [e.g. 5.2.2]: Plone 6.0.0
  • Plone REST API Version: plone.restapi 8.32.6

UPDATE

The underlying issue that is causing the RecursionError in my case is circular dependency between objects connected through Relations in a custom content-type design.

  • For Example, this is a definition of a custom content-type schema, having a RelationList attribute called RelatedItems

      class IType:
          // RelatedItems  
          relatedItems = RelationList(
              title=_(u"Related Items"),
              description=_(u"One or more links to related items"),
              required=False,
          )
    
  • Now when I create 2 new Files of IType with the following connections: image

I get the error when accessing the Folder that contains those 2 objects. The error tracks to <Plone-Site>/backend/lib64/python3.9/site-packages/plone/restapi/serializer/summary.py

  • Code Error: relatedItems is in self.metadata_fields() on line 102 and not being ignored on line 104 image

  • Logs: image

Creating a Relation List using 18.6. Creating content types TTW will not in self.metadata_fields() - thus it will not fire json_compatible()

  • Issue reproduced on newer version of Plone.

FarooqAlaulddin avatar Apr 11 '23 04:04 FarooqAlaulddin

Hey there ! I wanna work on this but I can't find in which folder or file are u describing ?

Ashutosh-Singh-10 avatar Apr 13 '23 16:04 Ashutosh-Singh-10

@FarooqAlaulddin does this issue occur with the latest Volto? Perhaps check the Release Notes to see if the issue has been addressed.

@Ashutosh-Singh-10 this might have been solved already. Please read and follow Contributing to Plone and First-time contributors.

stevepiercy avatar Apr 13 '23 21:04 stevepiercy

@Ashutosh-Singh-10 I believe: Problem seem to appear when a content-type file has multiple (14+) RelatedItems property that contain a link to other content-types files (not a regular.pdf for example) which in turn may contain a link to the same file of the search or other files of the same content-type. This way the @search endpoint will keep exploring all possibilities since metadata_fields=_all Plone Rest API - metadata_fields setting it to relatedItems or _all would cause the problem.

// RelatedItems  
RelatedItems = RelationList(
    title=_(u"Related Items"),
    description=_(u"One or more links to related items"),
    required=False,
)

@stevepiercy I am not sure if I miss anything but I went through the bug fixes in the release notes and I did not see a similar issue title. Currently trying to test on newer version.

FarooqAlaulddin avatar Apr 14 '23 11:04 FarooqAlaulddin

@FarooqAlaulddin has this been resolved with a recent release of Volto? There have been numerous bugfixes since you initially reported this issue.

stevepiercy avatar Jan 29 '25 20:01 stevepiercy

@stevepiercy This is not a volto issue. It's an issue in plone.restapi if relatedItems is included in the summary metadata fields and there are items that create a cycle of relatedItems references.

davisagli avatar Jan 29 '25 20:01 davisagli