XML Tree depth greater than 50

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
I was creating response grids and received this message:

"System.XmlException: XML Tree depth greater than 50 An unexpected error has occurred. Your solution provider has been notified. (skuid)

I cannot even open the page.
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
Bill, you'll need to go to the Pages list, find your page, and use the Versions row action to find the most recent auto-save version, and revert to it.

The "XML Tree Depth" limit is a known issue that right now the best way to avoid is to reorganize your pages to avoid having extremely deep XML trees. 
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
I am trying to open the last version but freezes.  The name of the page is: "D_Detail_CR_Member_DNA"  
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
I'd keep going backwards trying previous versions until you find one that works.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
Another alternative is to try to open the most recent version, but replace "PageBuilder" in your URL with "PageXMLEdit" and then you will get taken to the XML editor. There you can find the deepest point of your XML and attempt to remove pieces that way.
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
I have tried to go to :
https://dorothy--skuid.na16.visual.force.com/apex/PageXMLEdit?D_Detail_CR_Member_DNA

But I get the "Loading" screen.
I have given you access
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
That link will not work, you need to provide the ID of the page to edit, not the name (plus in the URL above you are not providing any URL parameters at all). You need to go to the Pages list, and click to edit your page. Then, find "PageBuilder" in the URL and replace it with "PageXMLEdit".
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
Ok. I was able to get in but I have now idea how to change the xml or what to change or why this happened.  Salesforce also does not know.
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
Bill, we have fixed the page to make it usable again by commenting out the Grid contained in the Popup for your "Select Document" section. We added a Template component to the page where we did this, making a note that we did this. You can retrieve the contents of this Grid by going to line 1909 of the XML for this page as it stands right now.

Please refresh this page before making any further edits, or revert to the named version "Working - edited by Skuid Support" if you need to go back and find the page at the state where we edited it:

Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
I must not done it correctly as I can not get in.  I tried to restore my 1:00 PM version, save it and it failed.  So, can you do it again.   I have had the "Select document"  window in page for months.  I have spent the last 3 days changing the page over to a responsive page.  So, I do not know what not to do going forward.
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 2,996 Points 2k badge 2x thumb
Bill,

I think it'd be helpful to define what is meant by "XML Tree depth". Skuid pages are stored as an XML document. XML is a hierarchically structured set of "nodes" that resembles a tree, where the top level node is the "trunk" (also called the "root") and its child nodes are branches.

For example, here is a simple Skuid page with no models and a template contained within a wrapper. The "skuidpage" node is the trunk with two branches, "models" and "components".
<skuidpage>
<models/>
<components>
<wrapper uniqueid="sk-ZayGn-60">
<components>
<template multiple="false" uniqueid="sk-Zazqa-67">
<contents>Hello World</contents>
</template>
</components>
</wrapper>
</components>
</skuidpage>

The "depth" (a confusing term given we're talking about a "tree") is a simple measure of how many steps we've taken away from the trunk. So "skuidpage" is at a "depth" of 0, the "models" and "components" nodes are both at depth 1. The "wrapper" node is at depth 2, etc., down to the "template" node at depth 4 and its "contents" node at depth 5.

  • 0. skuidpage

  • 1. components

  • 2. wrapper

  • 3. components

  • 4. template

  • 5. contents


As we increase the complexity of the page (by moving the wrapper into a panel set, for example), the depth of the template component increases:
<skuidpage>
<models/>
<components>
<panelset type="standard" uniqueid="sk-Zcj6D-64" scroll="">
<panels>
<panel>
<components>
<wrapper uniqueid="sk-ZayGn-60">
<components>
<template multiple="false" uniqueid="sk-Zazqa-67">
<contents>Hello World</contents>
</template>
</components>
</wrapper>
</components>
</panel>
</panels>
</panelset>
</components>
</skuidpage>


  • 0. skuidpage

  • 1. components

  • 2. panelset

  • 3. panels

  • 4. panel

  • 5. components

  • 6. wrapper

  • 7. components

  • 8. template

  • 9. contents


Our template is now at a depth of 8 and its contents node is at a depth of 9.

Now, your browser (IE, Chrome, etc) has a built-in Javascript XML parser which is what we use in the composer to build your page. As you drag and drop elements, we modify the XML document appropriately. Your browser's XML parser doesn't really care how deeply nested the nodes of your XML document are... it only cares about the "size" (number of characters), the limit for which is so large that you'll run into other problems before you ever hit it.

But, as soon as you save and then reload the page (either in the composer or the page preview), we process that XML document using Salesforce's XML parser. This is where you are running into trouble. Salesforce appears to have an undocumented depth limit built into its XML parser. I don't know why they chose to do this (probably another safeguard against over-utilization of shared resources), but once your deepest node surpasses a depth of 50, the XML parser will refuse to process it and we can no longer load the page.

If this happens, then the only solution is to either restore a previous, working version of the page or to open Skuid's XML page editor and remove the offending nodes. You can just copy and paste the following URL to access Skuid's XML page editor:
https://YOUR_ORGS_DOMAIN (e.g. skuid.na11.visual.force.com)/apex/skuid__PageXMLEdit?id=THE_PAGE_ID (e.g. a02G000000UvFmrIAF)

You need to be careful to remove everything between the beginning and ending tags (otherwise you end up with an imbalanced document. Kind of like how I just left off the ending parenthesis on the previous sentence. Here's an example of what your document will look like, with the text that needs to be deleted highlighted in red:



You could also try removing one of the container components, though this tends to be trickier and more error prone (so proceed with caution):



Hitting this limit is very rare, but we are investigating how we might prevent or resolve this issue automatically in the future. In the meantime, restoring prior versions or manually editing the XML are the only options.
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 2,996 Points 2k badge 2x thumb
If you would like to petition Salesforce to remove or increase this arbitrary limit, please visit the IdeaExchange and vote for it:

https://success.salesforce.com/ideaView?id=08730000000Drs2AAC
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
I voted yes.
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
JD.  Thanks for the tutorial.  It would be nice to have a warning but now I get it.  I was able to rebuild the page.  Thanks.
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,270 Points 5k badge 2x thumb
Thanks for this post. Just hit the limit with a filter on reference field in a field editor in a tabset in a popup from a page title in grid in a tabset in a drawer in a table in a tabset. Vote added to SF Idea. 
(Edited)
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
That is some deep XML :)
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,270 Points 5k badge 2x thumb
...tabset is also in a panel set in another panel set in a wrapper. So, able to fix by removing some excessive nesting. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
That's the Skuid tongue-twister...
Photo of Bill Fox

Bill Fox

  • 7,904 Points 5k badge 2x thumb
Just hit it again.  Frustrating