{"record":{"id":"1a2ce7b876aed1a0","repo":"pentaho/pentaho-kettle","slug":"samplerowsmeta-exception-unabletoreadstepinfo","errorCode":null,"errorMessage":"SampleRowsMeta.Exception.UnableToReadStepInfo","messagePattern":"SampleRowsMeta\\.Exception\\.UnableToReadStepInfo","errorType":"exception","errorClass":"KettleXMLException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/samplerows/SampleRowsMeta.java","lineNumber":88,"sourceCode":"\n  @Override\n  public void getFields( Bowl bowl, RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,\n    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {\n    if ( !Utils.isEmpty( linenumfield ) ) {\n\n      ValueMetaInterface v = new ValueMetaInteger( space.environmentSubstitute( linenumfield ) );\n      v.setLength( ValueMetaInterface.DEFAULT_INTEGER_LENGTH, 0 );\n      v.setOrigin( name );\n      inputRowMeta.addValueMeta( v );\n    }\n  }\n\n  private void readData( Node stepnode, List<DatabaseMeta> databases ) throws KettleXMLException {\n    try {\n      linesrange = XMLHandler.getTagValue( stepnode, \"linesrange\" );\n      linenumfield = XMLHandler.getTagValue( stepnode, \"linenumfield\" );\n    } catch ( Exception e ) {\n      throw new KettleXMLException(\n        BaseMessages.getString( PKG, \"SampleRowsMeta.Exception.UnableToReadStepInfo\" ), e );\n    }\n  }\n\n  public String getLinesRange() {\n    return this.linesrange;\n  }\n\n  public void setLinesRange( String linesrange ) {\n    this.linesrange = linesrange;\n  }\n\n  public String getLineNumberField() {\n    return this.linenumfield;\n  }\n\n  public void setLineNumberField( String linenumfield ) {\n    this.linenumfield = linenumfield;","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/samplerows/SampleRowsMeta.java#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the .ktr in an XML editor, fix the SampleRows step block ensuring <linesrange> and <linenumfield> tags are present and well-formed.","Check the wrapped cause in the stack trace for the exact parse error and line.","Re-add the Sample Rows step in Spoon and re-save to regenerate valid XML.","Validate the whole file with an XML parser (xmllint) before opening in Spoon."],"exampleFix":"// before: missing tag breaks expected structure\n<step><name>Sample rows</name></step>\n// after\n<step><name>Sample rows</name><linesrange>1..10</linesrange><linenumfield>linenum</linenumfield></step>","handlingStrategy":"try-catch","validationCode":"// Validate XML before loading the transformation\ntry (InputStream in = new FileInputStream(\"trans.ktr\")) {\n  Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);\n  if (doc.getElementsByTagName(\"linesrange\").getLength() == 0) log.warn(\"SampleRows step missing linesrange\");\n}","typeGuard":"Node node = XMLHandler.getSubNode(stepnode, \"linesrange\");\nif (node == null) { throw new IllegalArgumentException(\"SampleRows step XML missing <linesrange>\"); }","tryCatchPattern":"try {\n  transMeta = new TransMeta(\"trans.ktr\");\n} catch (KettleXMLException e) {\n  log.error(\"SampleRows XML load failed: {}\", e.getCause(), e);\n  // restore from version-controlled copy\n}","preventionTips":["Edit transformations in Spoon, not in a text editor.","Validate .ktr files with an XML parser before distribution.","Transfer files in binary mode to avoid truncation/corruption.","Keep known-good copies under version control."],"tags":["kettle","xml","deserialization","transformation-metadata"],"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"}