Application crash: Circular dependencies in form element

Vote:
 

A client of mine managed to crash the site when creating a form.

He noticed that when opening a form field to add a dependency, the list of dependent elements was empty.
While i was troubleshooting i noticed that the following endpoint  timed out: /EPiServer/EPiServer.Forms.UI/Stores/formselement/<formfieldId>?parentLink=<parentId>&query=GetAllDependees

After digging around in optimizely dlls i found the code that was the culpit namely EPiServer.Forms.Core.Internal.Dependency.DependencyService -> BuildDependencyList

This method caused a stack overflow exception because  FormField#1 had a dependency to FormField#2 and FormField#2 had a dependency to FormField#1.

There are built in safe guards to prevent this from happening. When you open the tool to select which field you want to create a dependency on, you only see fields that doesn't already have a dependency to the field you are working with.
So if you have a form with FormField#1, FormField#2 and FormField#3 and you have created a dependency so that FormField#1 is dependant on FormField#2 then if you try to create a dependency on FormField#2 you should only see FormField#3 in the list of possible dependencies.

This safeguard only works on published versions of the form field though. Meaning if you set the dependency between FormField#1 and FormField#2 and don't actually publish that change and then go to FormField#2 and open the list of dependent fields then you will se FormField#1 there even though it has a dependency to FormField#2. If you then publish FormField#2 and go to FormField#1 and also publish that, then you have created a circular dependency and you will crash the application if you try to open the list of dependency fields

What probably needs to be fixed by optimizely is for them to check on publishing that a circular dependency isn't being publish and also making sure that BuildDependencyList doesn't cause stack overflow exception

 

To reproduce (if above explaination isn't enough)

  1. Create a form
  2. Create two form fields (lets call them field1 and field2)
  3. Create a dependency so field1 is dependant on field2
  4. Save (dont publish)
  5. Create a dependency so field2 is depenant on field1
  6. Publish
  7. Go back to field1
  8. Publish

Open any of the field and try to add a new dependeny. The application will crash when you open the tooling to pick which field the current field should be dependant on

#338061
May 08, 2025 14:02
Vote:
 

Great find.

To be sure it is handled, report it on support.optimizely.com. I don't think they pick up bug reports from these forums regularly.

#338314
May 18, 2025 20:27
* 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.