pentaho/pentaho-kettle · error · RuntimeException

Row.ErrorDeserializing

Error message

Row.ErrorDeserializing

What it means

The 3-argument form of substr wraps any exception raised while computing substring(from, from+len) into this Rhino runtime error with e.getMessage() appended. Even though negative start has its own guard, failures such as a non-numeric length (NaN), a non-convertible string argument, or an internal conversion error surface here. The 'to' index is clamped to the string length, so most numeric inputs should pass - failures indicate conversion problems.

Solutions

  1. Ensure start and len are finite numbers: substr(str, Number(start), Number(len)).
  2. Guard the input string: if (str == null) str = ''.
  3. Validate len is not NaN: var l = isNaN(len) ? 0 : len; before calling.
  4. Use native JavaScript slice/substring for standard semantics.

Example fix

// before
substr(value, startField, lenField); // lenField may be empty -> NaN
// after
var s = String(value == null ? "" : value);
substr(s, parseInt(startField, 10) || 0, parseInt(lenField, 10) || 0);
Defensive patterns

Strategy: validation

Validate before calling

var s = String(str == null ? "" : str);
var st = Number(start) || 0;
var ln = isNaN(Number(len)) ? 0 : Math.round(Number(len));

Type guard

function isFiniteNumber(x) { return typeof x === "number" && isFinite(x); }

Try / catch

var r;
try {
  r = substr(s, st, ln);
} catch (e) {
  r = "";
}

Prevention

When it happens

Trigger: Calling substr(str, start, len) with 3 arguments where Context.toNumber fails for start or len (NaN causing invalid substring bounds), or the first argument cannot be converted to a string.

Common situations: Passing empty/null fields that convert to NaN; passing a numeric string with locale-specific decimal separators; passing a JavaScript object as the length argument.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/compatibility/Row.java:942

    try {
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      DataOutputStream dataOutputStream = new DataOutputStream( byteArrayOutputStream );
      row.writeData( dataOutputStream );
      dataOutputStream.close();
      byteArrayOutputStream.close();
      return byteArrayOutputStream.toByteArray();
    } catch ( Exception e ) {
      throw new RuntimeException( BaseMessages.getString( PKG, "Row.ErrorSerializing" ) + row, e );
    }
  }

  public static final Row getRow( byte[] data, Row metadata ) {
    try {
      ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( data );
      DataInputStream dataInputStream = new DataInputStream( byteArrayInputStream );
      return new Row( dataInputStream, metadata.size(), metadata );
    } catch ( Exception e ) {
      throw new RuntimeException( BaseMessages.getString( PKG, "Row.ErrorDeserializing" ), e );
    }
  }

  /**
   * @return the usedValueListeners
   */
  public List<ValueUsedListener> getUsedValueListeners() {
    return usedValueListeners;
  }

  /**
   * @param usedValueListeners
   *          the usedValueListeners to set
   */
  public void setUsedValueListeners( List<ValueUsedListener> usedValueListeners ) {
    this.usedValueListeners = usedValueListeners;
  }

View on GitHub (pinned to f3058517a1)