{"record":{"id":"16d3f51dd4519800","repo":"pentaho/pentaho-kettle","slug":"xmlinputstream-log-toomanynestedelements","errorCode":null,"errorMessage":"XMLInputStream.Log.TooManyNestedElements","messagePattern":"XMLInputStream\\.Log\\.TooManyNestedElements","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmlinputstream/XMLInputStream.java","lineNumber":363,"sourceCode":"        // unknown eventType\n        outputRowData[data.pos_xml_data_type_description] = eventDescription[0] + \"(\" + eventType + \")\";\n      } else {\n        outputRowData[data.pos_xml_data_type_description] = eventDescription[eventType];\n      }\n    }\n    if ( data.pos_xml_location_line != -1 ) {\n      outputRowData[data.pos_xml_location_line] = new Long( e.getLocation().getLineNumber() );\n    }\n    if ( data.pos_xml_location_column != -1 ) {\n      outputRowData[data.pos_xml_location_column] = new Long( e.getLocation().getColumnNumber() );\n    }\n\n    switch ( eventType ) {\n\n      case XMLStreamConstants.START_ELEMENT:\n        data.elementLevel++;\n        if ( data.elementLevel > PARENT_ID_ALLOCATE_SIZE - 1 ) {\n          throw new KettleException(\n            BaseMessages.getString( PKG, \"XMLInputStream.Log.TooManyNestedElements\", PARENT_ID_ALLOCATE_SIZE ) );\n        }\n        if ( data.elementParentID[data.elementLevel] == null ) {\n          data.elementParentID[data.elementLevel] = data.elementID;\n        }\n        data.elementID++;\n        data.elementLevelID[data.elementLevel] = data.elementID;\n\n        String xml_data_name;\n        if ( meta.isEnableNamespaces() ) {\n          String prefix = e.asStartElement().getName().getPrefix();\n          if ( Utils.isEmpty( prefix ) ) {\n            xml_data_name = e.asStartElement().getName().getLocalPart();\n          } else { // add namespace prefix:\n            xml_data_name = prefix + \":\" + e.asStartElement().getName().getLocalPart();\n          }\n        } else {\n          xml_data_name = e.asStartElement().getName().getLocalPart();","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/xml/core/src/main/java/org/pentaho/di/trans/steps/xmlinputstream/XMLInputStream.java#L345-L381","documentation":"XMLInputStream.processEvent throws a KettleException with 'XMLInputStream.Log.TooManyNestedElements' when the XML document nesting depth exceeds PARENT_ID_ALLOCATE_SIZE - 1 during a START_ELEMENT event. The step pre-allocates the elementParentID tracking array and refuses documents nested deeper than that fixed limit.","triggerScenarios":"processEvent (called from getRowFromXML) on XMLStreamConstants.START_ELEMENT: data.elementLevel++ pushes elementLevel beyond PARENT_ID_ALLOCATE_SIZE - 1, i.e. the streamed document has more nesting levels than the step supports.","commonSituations":"Processing deeply nested XML generated by recursive schemas, machine-generated XML with excessive wrapper depth, or XML where the chosen encoding/loop path forces the reader to traverse very deep subtrees.","solutions":["Flatten or pre-process the XML (XSLT or an external preprocessing step) to reduce nesting depth below the limit.","Raise the source-side limit: increase PARENT_ID_ALLOCATE_SIZE in XMLInputStream.java and rebuild the plugin (check the installed version - later PDI versions allocate more).","Use the non-streaming 'Get XML Data' step or XPath-based parsing, which does not track element levels in a fixed array.","Point the streaming reader at a shallower subtree (adjust the encoding/loop settings) so deep branches are not traversed."],"exampleFix":"// before (plugin source)\nprivate static final int PARENT_ID_ALLOCATE_SIZE = 500;\n// after (rebuild plugin)\nprivate static final int PARENT_ID_ALLOCATE_SIZE = 5000; // supports deeper documents","handlingStrategy":"validation","validationCode":"// Count max nesting depth before streaming the document\nint maxDepth( Node n, int d ) {\n  int m = d;\n  for ( Node c = n.getFirstChild(); c != null; c = c.getNextSibling() ) {\n    if ( c.getNodeType() == Node.ELEMENT_NODE ) m = Math.max( m, maxDepth( c, d + 1 ) );\n  }\n  return m;\n}\n// reject if maxDepth( doc.getDocumentElement(), 1 ) > 499","typeGuard":null,"tryCatchPattern":"try { trans.execute( null ); } catch ( KettleException e ) { if ( e.getMessage().contains( \"TooManyNestedElements\" ) ) { log.error( \"Document nesting exceeds plugin limit - pre-process with XSLT\" ); } else { throw e; } }","preventionTips":["Know the depth limit of your PDI version's XML Input Stream plugin.","Flatten deeply nested supplier XML with XSLT before streaming.","Prefer GetXMLData/XPath parsing for documents with unbounded nesting."],"tags":["pentaho-kettle","xml","streaming","limit-exceeded"],"backgroundTag":"value-out-of-range","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}