pentaho/pentaho-kettle · error · KettleXMLException

SampleRowsMeta.Exception.UnableToReadStepInfo

Error message

SampleRowsMeta.Exception.UnableToReadStepInfo

What it means

KettleXMLException thrown by SampleRowsMeta.readData when reading the 'Sample rows' step's XML fails. Only two attributes are read (linesrange, linenumfield) inside a try/catch, and any exception (malformed XML, missing node) is wrapped with the localized message SampleRowsMeta.Exception.UnableToReadStepInfo.

Solutions

  1. Open the .ktr in an XML editor, fix the SampleRows step block ensuring <linesrange> and <linenumfield> tags are present and well-formed.
  2. Check the wrapped cause in the stack trace for the exact parse error and line.
  3. Re-add the Sample Rows step in Spoon and re-save to regenerate valid XML.
  4. Validate the whole file with an XML parser (xmllint) before opening in Spoon.

Example fix

// before: missing tag breaks expected structure
<step><name>Sample rows</name></step>
// after
<step><name>Sample rows</name><linesrange>1..10</linesrange><linenumfield>linenum</linenumfield></step>
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate XML before loading the transformation
try (InputStream in = new FileInputStream("trans.ktr")) {
  Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
  if (doc.getElementsByTagName("linesrange").getLength() == 0) log.warn("SampleRows step missing linesrange");
}

Type guard

Node node = XMLHandler.getSubNode(stepnode, "linesrange");
if (node == null) { throw new IllegalArgumentException("SampleRows step XML missing <linesrange>"); }

Try / catch

try {
  transMeta = new TransMeta("trans.ktr");
} catch (KettleXMLException e) {
  log.error("SampleRows XML load failed: {}", e.getCause(), e);
  // restore from version-controlled copy
}

Prevention

When it happens

Trigger: loadXML deserializes a .ktr containing a Sample Rows step and XMLHandler.getTagValue(stepnode, ...) throws because the node structure is malformed or the step node is not the expected element.

Common situations: Hand-edited .ktr with broken XML; file truncated by a bad transfer; step XML copied from another step type so expected tags are absent; version mismatch in saved attributes.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/samplerows/SampleRowsMeta.java:88

  @Override
  public void getFields( Bowl bowl, RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
    if ( !Utils.isEmpty( linenumfield ) ) {

      ValueMetaInterface v = new ValueMetaInteger( space.environmentSubstitute( linenumfield ) );
      v.setLength( ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0 );
      v.setOrigin( name );
      inputRowMeta.addValueMeta( v );
    }
  }

  private void readData( Node stepnode, List<DatabaseMeta> databases ) throws KettleXMLException {
    try {
      linesrange = XMLHandler.getTagValue( stepnode, "linesrange" );
      linenumfield = XMLHandler.getTagValue( stepnode, "linenumfield" );
    } catch ( Exception e ) {
      throw new KettleXMLException(
        BaseMessages.getString( PKG, "SampleRowsMeta.Exception.UnableToReadStepInfo" ), e );
    }
  }

  public String getLinesRange() {
    return this.linesrange;
  }

  public void setLinesRange( String linesrange ) {
    this.linesrange = linesrange;
  }

  public String getLineNumberField() {
    return this.linenumfield;
  }

  public void setLineNumberField( String linenumfield ) {
    this.linenumfield = linenumfield;

View on GitHub (pinned to f3058517a1)