{"record":{"id":"27f3c93da14de82c","repo":"pentaho/pentaho-kettle","slug":"scriptmeta-exception-unabletoloadstepinfofromxml","errorCode":null,"errorMessage":"ScriptMeta.Exception.UnableToLoadStepInfoFromXML","messagePattern":"ScriptMeta\\.Exception\\.UnableToLoadStepInfoFromXML","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptMeta.java","lineNumber":250,"sourceCode":"      int nrfields = XMLHandler.countNodes( fields, \"field\" );\n\n      allocate( nrfields );\n\n      for ( int i = 0; i < nrfields; i++ ) {\n        Node fnode = XMLHandler.getSubNodeByNr( fields, \"field\", i );\n\n        fieldname[i] = XMLHandler.getTagValue( fnode, \"name\" );\n        rename[i] = XMLHandler.getTagValue( fnode, \"rename\" );\n        type[i] = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fnode, \"type\" ) );\n\n        String slen = XMLHandler.getTagValue( fnode, \"length\" );\n        String sprc = XMLHandler.getTagValue( fnode, \"precision\" );\n        length[i] = Const.toInt( slen, -1 );\n        precision[i] = Const.toInt( sprc, -1 );\n        replace[i] = \"Y\".equalsIgnoreCase( XMLHandler.getTagValue( fnode, \"replace\" ) );\n      }\n    } catch ( Exception e ) {\n      throw new KettleXMLException( BaseMessages.getString(\n        PKG, \"ScriptMeta.Exception.UnableToLoadStepInfoFromXML\" ), e );\n    }\n  }\n\n  public void setDefault() {\n    jsScripts = new ScriptValuesScript[1];\n    jsScripts[0] =\n      new ScriptValuesScript( ScriptValuesScript.TRANSFORM_SCRIPT, BaseMessages\n        .getString( PKG, \"Script.Script1\" ), \"//\"\n        + BaseMessages.getString( PKG, \"Script.ScriptHere\" ) + Const.CR + Const.CR );\n\n    int nrfields = 0;\n    allocate( nrfields );\n\n    for ( int i = 0; i < nrfields; i++ ) {\n      fieldname[i] = \"newvalue\";\n      rename[i] = \"newvalue\";\n      type[i] = ValueMetaInterface.TYPE_NUMBER;","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptMeta.java#L232-L268","documentation":"readData() parses the serialized XML of the Script step (fields, scripts, jsScripts) via XMLHandler. Any parse error or unexpected structure causes it to wrap the exception in a KettleXMLException with message key 'ScriptMeta.Exception.UnableToLoadStepInfoFromXML', thrown from loadXML during step metadata deserialization.","triggerScenarios":"Loading a .ktr transformation whose <step type='Script'> XML is malformed, was produced by an incompatible PDI version, or has missing tags like field_name/field_type/replace.","commonSituations":"Opening transformations exported from newer/older Pentaho versions; hand-edited XML; truncated or corrupted .ktr files; repository import of foreign metadata.","solutions":["Open the .ktr in a text editor and validate the Script step's XML block against a working example from the same PDI version.","Recreate the Script step in Spoon and re-enter the script/fields instead of editing XML manually.","Align the PDI version used to open the transformation with the version that created it.","Check the nested cause ('Caused by') for the exact XMLHandler failure (missing tag, bad number)."],"exampleFix":"// before: hand-edited step XML missing required tag\n<replace>X</replace>\n// after: use valid boolean value\n<replace>Y</replace>","handlingStrategy":"try-catch","validationCode":"// Before loading, sanity-check the Script step XML block\n// (every field node has name/type/length/precision/replace tags)\ngrep -c '<field_name>' yourTransformation.ktr","typeGuard":null,"tryCatchPattern":"try { transMeta.loadXML(file, ...); } catch (KettleXMLException e) {\n  log.error(\"Script step XML load failed: \" + e.getCause(), e);\n  // fall back to re-creating the step or an earlier backup file\n}","preventionTips":["Don't hand-edit .ktr XML; edit in Spoon","Keep PDI versions consistent across environments","Keep transformation files under version control","Export a known-good copy before risky edits"],"tags":["xml","pdi","deserialization","kettle"],"backgroundTag":"xml-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"}