pentaho/pentaho-kettle · error · KettleXMLException

DetectLastRowMeta.Exception.UnableToReadStepInfo

DetectLastRowMeta.Exception.UnableToReadStepInfo

Error message

DetectLastRowMeta.Exception.UnableToReadStepInfo

What it means

DetectLastRowMeta.readData wraps any exception while parsing the step's XML node (resultfieldname tag) into a KettleXMLException with this localized message. It is thrown during loadXML when the step definition XML in a .ktr file cannot be read, with the original cause chained.

Solutions

  1. Open the .ktr in a text editor and verify the <detect_last_row> step node and its resultfieldname tag are intact
  2. Re-export or re-save the transformation in Spoon to regenerate valid XML
  3. Check file encoding and XML well-formedness with an XML validator
  4. Restore the transformation from a known-good backup or VCS history

Example fix

// before
resultfieldname = XMLHandler.getTagValue( stepnode, "resultfieldname" );
// after: tolerate a missing tag and apply a default
resultfieldname = XMLHandler.getTagValue( stepnode, "resultfieldname" );
if ( resultfieldname == null ) {
  resultfieldname = "result";
}
Defensive patterns

Strategy: try-catch

Validate before calling

// validate the .ktr XML is well-formed before loading
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.parse(new File("trans.ktr")); // throws SAXException on malformed XML

Try / catch

try {
  transMeta = new TransMeta(inputStream, metadataProvider, true, variables, null);
} catch (KettleXMLException e) {
  if (e.getMessage() != null && e.getMessage().contains("UnableToReadStepInfo")) {
    log.error("DetectLastRow step XML is malformed; cause: " + e.getCause(), e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Loading a transformation XML (KettleXMLException path via loadXML) whose DetectLastRow step node is malformed, empty, or contains invalid XML entities; XMLHandler.getTagValue throwing on corrupted content.

Common situations: Hand-edited or truncated .ktr files; transformations exported from different Pentaho versions with changed tag names; XML encoding issues; file corruption in version control or transfer.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/7c8448323218e5bc. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/detectlastrow/DetectLastRowMeta.java:107

    if ( !Utils.isEmpty( resultfieldname ) ) {
      ValueMetaInterface v =
        new ValueMetaBoolean( space.environmentSubstitute( resultfieldname ) );
      v.setOrigin( name );
      row.addValueMeta( v );
    }
  }

  public String getXML() {
    StringBuilder retval = new StringBuilder();
    retval.append( "    " + XMLHandler.addTagValue( "resultfieldname", resultfieldname ) );
    return retval.toString();
  }

  private void readData( Node stepnode ) throws KettleXMLException {
    try {
      resultfieldname = XMLHandler.getTagValue( stepnode, "resultfieldname" );
    } catch ( Exception e ) {
      throw new KettleXMLException( BaseMessages.getString(
        PKG, "DetectLastRowMeta.Exception.UnableToReadStepInfo" ), e );
    }
  }

  public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {
    try {
      resultfieldname = rep.getStepAttributeString( id_step, "resultfieldname" );
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString(
        PKG, "DetectLastRowMeta.Exception.UnexpectedErrorReadingStepInfo" ), e );
    }
  }

  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {
    try {
      rep.saveStepAttribute( id_transformation, id_step, "resultfieldname", resultfieldname );
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG, "DetectLastRowMeta.Exception.UnableToSaveStepInfo" )

View on GitHub (pinned to f3058517a1)