{"record":{"id":"63dca5b14d00f40d","repo":"pentaho/pentaho-kettle","slug":"stringcutmeta-exception-unabletoreadstepinfofromxml","errorCode":null,"errorMessage":"StringCutMeta.Exception.UnableToReadStepInfoFromXML","messagePattern":"StringCutMeta\\.Exception\\.UnableToReadStepInfoFromXML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/stringcut/StringCutMeta.java","lineNumber":160,"sourceCode":"\n  private void readData( Node stepnode ) throws KettleXMLException {\n    try {\n      int nrkeys;\n\n      Node lookup = XMLHandler.getSubNode( stepnode, \"fields\" );\n      nrkeys = XMLHandler.countNodes( lookup, \"field\" );\n\n      allocate( nrkeys );\n\n      for ( int i = 0; i < nrkeys; i++ ) {\n        Node fnode = XMLHandler.getSubNodeByNr( lookup, \"field\", i );\n        fieldInStream[i] = Const.NVL( XMLHandler.getTagValue( fnode, \"in_stream_name\" ), \"\" );\n        fieldOutStream[i] = Const.NVL( XMLHandler.getTagValue( fnode, \"out_stream_name\" ), \"\" );\n        cutFrom[i] = Const.NVL( XMLHandler.getTagValue( fnode, \"cut_from\" ), \"\" );\n        cutTo[i] = Const.NVL( XMLHandler.getTagValue( fnode, \"cut_to\" ), \"\" );\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"StringCutMeta.Exception.UnableToReadStepInfoFromXML\" ), e );\n    }\n  }\n\n  public void setDefault() {\n    fieldInStream = null;\n    fieldOutStream = null;\n\n    int nrkeys = 0;\n\n    allocate( nrkeys );\n  }\n\n  public String getXML() {\n    StringBuilder retval = new StringBuilder( 500 );\n\n    retval.append( \"    <fields>\" ).append( Const.CR );\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/stringcut/StringCutMeta.java#L142-L178","documentation":"StringCutMeta throws this KettleXMLException in readData() (invoked by loadXML) when parsing the step's XML definition fails unexpectedly. The message wraps the underlying exception from XMLHandler.getTagValue() or array handling. The transformation cannot load this step until the XML is fixed.","triggerScenarios":"Calling loadXML() on malformed step XML — e.g. a <fields> node with unexpected structure, a null/invalid field node, or DOM access errors while reading in_stream_name/out_stream_name/cut_from/cut_to tags.","commonSituations":"Hand-edited .ktr XML with a broken <field> entry; XML written by a different PDI version with a changed schema; truncated/corrupted file transfer.","solutions":["Inspect the wrapped cause to find the exact XML parse problem","Validate/repair the <fields><field> section of the step XML in the .ktr file","Re-export the step from Spoon to regenerate valid XML","Open the file in a text editor and compare the field node structure against a working example"],"exampleFix":"// before\n<field><in_stream_name>x</in_stream_name></field> <!-- missing cut tags, malformed -->\n// after\n<field><in_stream_name>x</in_stream_name><out_stream_name>y</out_stream_name><cut_from>0</cut_from><cut_to>5</cut_to></field>","handlingStrategy":"try-catch","validationCode":"// before loadXML, sanity-check the step XML\nNode fieldsNode = XMLHandler.getSubNode(stepnode, \"fields\");\nint count = fieldsNode == null ? 0 : XMLHandler.countNodes(fieldsNode, \"field\");\nfor (int i = 0; i < count; i++) {\n  Node f = XMLHandler.getSubNodeByNr(fieldsNode, \"field\", i);\n  if (f == null || XMLHandler.getTagValue(f, \"in_stream_name\") == null) {\n    throw new IllegalArgumentException(\"Malformed field node at index \" + i);\n  }\n}","typeGuard":"boolean hasWellFormedFields(Node stepnode) {\n  Node fields = XMLHandler.getSubNode(stepnode, \"fields\");\n  if (fields == null) return true; // zero-field step is valid\n  for (int i = 0; i < XMLHandler.countNodes(fields, \"field\"); i++) {\n    Node f = XMLHandler.getSubNodeByNr(fields, \"field\", i);\n    if (f == null) return false;\n  }\n  return true;\n}","tryCatchPattern":"try {\n  meta.loadXML(stepnode, databases, context);\n} catch (KettleXMLException e) {\n  logError(\"Corrupt StringCut XML: \" + e.getCause(), e);\n  meta.setDefault(); // load with defaults instead of failing the whole transform\n}","preventionTips":["Do not hand-edit .ktr XML; edit via Spoon","Validate .ktr files with an XML parser after merges or transfers","Keep transformations in version control and restore on corruption","Re-export from Spoon when upgrading PDI versions"],"tags":["xml","metadata-load","pdi","ktr"],"backgroundTag":"json-parse-error","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"}