{"record":{"id":"835946ac3f78d3e2","repo":"pentaho/pentaho-kettle","slug":"samplerowsmeta-exception-unexpectederrorsavingstepinfo","errorCode":null,"errorMessage":"SampleRowsMeta.Exception.UnexpectedErrorSavingStepInfo","messagePattern":"SampleRowsMeta\\.Exception\\.UnexpectedErrorSavingStepInfo","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/samplerows/SampleRowsMeta.java","lineNumber":131,"sourceCode":"\n  public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException {\n    try {\n      linesrange = rep.getStepAttributeString( id_step, \"linesrange\" );\n      linenumfield = rep.getStepAttributeString( id_step, \"linenumfield\" );\n\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"SampleRowsMeta.Exception.UnexpectedErrorReadingStepInfo\" ), e );\n    }\n  }\n\n  public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step ) throws KettleException {\n    try {\n      rep.saveStepAttribute( id_transformation, id_step, \"linesrange\", linesrange );\n      rep.saveStepAttribute( id_transformation, id_step, \"linenumfield\", linenumfield );\n\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString(\n        PKG, \"SampleRowsMeta.Exception.UnexpectedErrorSavingStepInfo\" ), e );\n    }\n  }\n\n  public String getXML() {\n    StringBuilder retval = new StringBuilder();\n    retval.append( \"    \" + XMLHandler.addTagValue( \"linesrange\", linesrange ) );\n    retval.append( \"    \" + XMLHandler.addTagValue( \"linenumfield\", linenumfield ) );\n\n    return retval.toString();\n  }\n\n  public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta,\n    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,\n    Repository repository, IMetaStore metaStore ) {\n    CheckResult cr;\n\n    if ( Utils.isEmpty( linesrange ) ) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/samplerows/SampleRowsMeta.java#L113-L149","documentation":"KettleException thrown by SampleRowsMeta.saveRep when saving the Sample Rows step's attributes (linesrange, linenumfield) to the repository fails. The localized message SampleRowsMeta.Exception.UnexpectedErrorSavingStepInfo wraps the original repository exception.","triggerScenarios":"saveRep runs during a transformation save and rep.saveStepAttribute throws due to a repository write failure (connection loss, permissions, constraint violation on R_STEP_ATTRIBUTE).","commonSituations":"Repository DB read-only or full; network drop between Spoon and repository database; DB user lacking INSERT/UPDATE grants; concurrent edits causing lock or key conflicts.","solutions":["Examine the wrapped cause; fix the underlying DB issue (connectivity, privileges, disk space).","Reconnect to the repository and retry the save.","Check for conflicting rows in R_STEP_ATTRIBUTE for the same id_step and remove duplicates.","As a workaround, save the transformation as XML to avoid losing work while repository access is fixed."],"exampleFix":"// before: saving while repository session expired\ntransMeta.saveRepo(repo, null); // KettleException: UnexpectedErrorSavingStepInfo\n// after: reconnect first\nif (!repo.isConnected()) repo.connect(user, pass);\ntransMeta.saveRepo(repo, null);","handlingStrategy":"try-catch","validationCode":"if (repository == null || !repository.isConnected()) {\n  throw new IllegalStateException(\"Repository must be connected before saving\");\n}","typeGuard":"if (linesrange == null || !linesrange.matches(\"^\\\\d+\\\\.\\\\.\\\\d+$\")) { log.warn(\"linesrange not set; saving null attribute\"); }","tryCatchPattern":"try {\n  meta.saveRep(repository, metaStore, idTransformation, idStep);\n} catch (KettleException e) {\n  log.error(\"SampleRows repository save failed: {}\", e.getCause(), e);\n  transMeta.saveXML(new File(\"backup.ktr\"), \"no-overwrite\"); // don't lose work\n}","preventionTips":["Save as XML backup before writing to a flaky repository.","Ensure the repository user has INSERT/UPDATE grants on R_STEP_ATTRIBUTE.","Watch for DB full/disk-space conditions in the repository database.","Reconnect after idle timeouts before saving."],"tags":["kettle","repository","metadata","persistence"],"backgroundTag":"database-write-failed","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"}