How to avoid circular reference in a content area when using the content delivery api?

Vote:
 

Hi,

We implemented this part of an optimizely article to expand multiple levels of nested ContentArea property. We plan on making this our default way to fetch data from the content delivery api:

https://docs.developers.optimizely.com/content-management-system/v1.5.0-content-delivery-api/docs/customizing-conversion-from-icontent-to-contentapimodel#example-expand-multiple-levels-of-nested-contentarea-property

Now we found an issue with this approach when there is a circular reference in the hierarchy of the fetched data. Where for example:                                      

'A ' contains a content area, inside of it is a content called 'B' that references back to 'A' in it's own content area as well.

From this we get a circular reference which would crash the application.

Any suggestion to help detect a circular reference when it happens to solve this issue?

Thanks in advance.

#321596
May 06, 2024 12:39
Vote:
 

Hi Taher,

First of all, I think we should make Allow Types tightly to restrict allowed types in content area first to avoid circurlar reference as much as possible. After that, you can add customized validation to check if there is any circular reference once saving content.

You can use GetReferencesToContent method from IContentRepository for circular reference validation.

#321639
Edited, May 07, 2024 3:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.