{"record":{"id":"616d0488ffb77d7e","repo":"pentaho/pentaho-kettle","slug":"row-rowerror","errorCode":null,"errorMessage":"Row.RowError","messagePattern":"Row\\.RowError","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Row.java","lineNumber":529,"sourceCode":"   * @param dis\n   *          The DataInputStream to read from\n   * @param size\n   *          the number or values to read\n   * @param meta\n   *          The description (name, type, length, precision) of the values to be read\n   * @throws KettleFileException\n   *           if the row couldn't be created by reading from the data input stream.\n   */\n  public Row( DataInputStream dis, int size, Row meta ) throws KettleFileException {\n    try {\n      // get all values in the row\n      for ( int i = 0; i < size; i++ ) {\n        addValue( new Value( meta.getValue( i ), dis ) );\n      }\n    } catch ( KettleEOFException e ) {\n      throw new KettleEOFException( BaseMessages.getString( PKG, \"Row.EndOfFileReadingRow\" ), e );\n    } catch ( Exception e ) {\n      throw new KettleFileException( BaseMessages.getString( PKG, \"Row.RowError\" ), e );\n    }\n  }\n\n  /**\n   * Write a row of Values to a DataOutputStream, without saving the meta-data.\n   *\n   * @param dos\n   *          The DataOutputStream to write to\n   * @return true if the row was written successfuly, false if something went wrong.\n   */\n  public boolean writeData( DataOutputStream dos ) throws KettleFileException {\n    // get all values in the row\n    for ( int i = 0; i < size(); i++ ) {\n      Value v = getValue( i );\n      v.writeData( dos );\n    }\n\n    return true;","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Row.java#L511-L547","documentation":"The substr scripting function wraps any exception from the 2-argument form (string conversion, number conversion of the start index, or String.substring) into this Rhino runtime error with e.getMessage() appended. It fires when exactly 2 arguments were passed but processing them failed. Common underlying causes are non-numeric start values and StringIndexOutOfBoundsException.","triggerScenarios":"Calling substr(str, start) with exactly 2 arguments where start is not convertible to a number (NaN), or str.substring(from) throws because from is out of range for the converted string.","commonSituations":"Passing a field that is null/empty causing Number conversion to NaN then an out-of-range substring; passing a non-numeric second argument like a string label; off-by-one assumptions vs JavaScript's native substr semantics.","solutions":["Ensure the second argument is a finite number: substr(str, Number(start)).","Guard the input string: if (str == null) str = ''; before calling.","Clamp the start index: var s = Math.max(0, Math.min(start, String(str).length)).","Consider native JavaScript substring/slice for predictable behavior."],"exampleFix":"// before\nsubstr(value, \"position\"); // non-numeric start\n// after\nsubstr(String(value), parseInt(pos, 10) || 0);","handlingStrategy":"validation","validationCode":"var s = String(str == null ? \"\" : str);\nvar start = Math.max(0, Math.round(Number(fromArg) || 0));\nif (start > s.length) start = s.length;","typeGuard":"function isFiniteNumber(x) { return typeof x === \"number\" && isFinite(x); }","tryCatchPattern":"var r;\ntry {\n  r = substr(String(str), Number(start) || 0);\n} catch (e) {\n  r = \"\"; // safe default on conversion failure\n}","preventionTips":["Ensure the start index is a finite number","Null-guard fields from previous steps","Clamp the start to [0, str.length]"],"tags":["javascript","string-processing","argument-count","scripting"],"backgroundTag":"invalid-argument-value","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"}