metadatacenter / cedar-project

Build project for all CEDAR Java repositories
https://github.com/metadatacenter/cedar-docs/wiki
Other
12 stars 1 forks source link

Fields close instantly, can't create metadata #1119

Open graybeal opened 3 years ago

graybeal commented 3 years ago

We found we couldn't create metadata in a VODAN Project Content template, the fields immediately closed.

Complicating things, after trying to generate metadata with the afflicted template, the same behavior happened on any other template until the cache was cleared.

graybeal commented 3 years ago

Marcos suspected a link to an element, "Type of service", that contained within it an empty element also called "Type of service."

I convinced myself that the fix to the "quick-close" fields is to delete the blank type of service element in the parent Type of Service element. Any template that has that empty element can't generate a healthy metadata editor. As soon as I get rid of it in a template and clear the cache on the new instance, it works fine.

I can guess how that probably got created, too. The template author works in multiple windows, and if she created the Type of Service element and saved right away (so it was empty at that point), then re-created another Type of Service and incorporated the first one, the included element would have been empty. Later she would have deleted the empty element from her workspace when she realized she had two.

I created a diffchecker at https://www.diffchecker.com/O7FdhHA6 showing the original and the modified element. It's kinda weird what was changed when I deleted the empty element. And what's also weird is I can't change the original bad element, only a copy of it.

So I went ahead and renamed the original element to add ' BAD' to its name, and made a new 'Type of service' element in its place that has the empty element deleted.

marcosmro commented 3 years ago

I've been looking into this issue in detail, and the workflow that you described, although it's uncommon, doesn't make the UI fail. The main problem with that element is that both 'Type of service' elements have the same identifier, and our UI cannot deal with an element nested into the same element. The result is an infinite loop. ($rootScope:infdig error in JS - see the screenshot below). In the steps you described, the two elements would have different identifiers, which is fine even if the nested one is empty.

Screen Shot 2021-04-09 at 12.26.50 PM.png

graybeal commented 3 years ago

So we know how to fix this if it occurs, but we just need to know how to make it happen so we can avoid that? Just including an element in itself won't do it, I presume.

marcosmro commented 3 years ago

Here are the steps to reproduce it:

  1. Create a new element E1. Save it.
  2. Open E1. Click on the magnifying glass icon on the sidebar and pick the same element (E1). Save it. By doing that, we are inserting a previous version of E1 into E1. Both E1's have the same @id, but one is nested into the other one, and that causes an infinite loop in JS.
  3. Create a template and insert E1 into it.