pentaho/pentaho-kettle · error · RuntimeException

Problem with clone row detected in RowMetaAndData

Error message

Problem with clone row detected in RowMetaAndData

What it means

RowMetaAndData.clone() deep-copies the row metadata and data via rowMeta.cloneRow(data). If cloneRow raises KettleValueException (a data conversion problem cloning one of the value objects), the method converts it to a RuntimeException since Object.clone() cannot throw checked exceptions.

Solutions

  1. Ensure rowMeta matches the actual value objects in data (rebuild RowMetaAndData if metadata changed)
  2. Inspect the cause KettleValueException to identify which field fails conversion
  3. Use safe conversions when building rows (ValueDataUtil / correct ValueMeta types)
  4. Wrap clone in try-catch and copy the row field-by-field as a fallback

Example fix

// before
RowMetaAndData copy = rowMetaAndData.clone();
// after
RowMetaAndData copy;
try {
  copy = rowMetaAndData.clone();
} catch (RuntimeException e) {
  copy = manualCopy(rowMetaAndData); // field-by-field copy with ValueDataUtil
}
Defensive patterns

Strategy: try-catch

Validate before calling

// check metadata/data consistency before cloning
for (int i = 0; i < rmad.getRowMeta().size(); i++) {
  Object v = rmad.getData()[i];
  if (v != null && !rmad.getRowMeta().getValueMeta(i).getType()
      .equals(ValueMetaFactory.getIdForValueMeta(v.getClass().getSimpleName())) ) { /* log mismatch */ }
}

Try / catch

try {
  RowMetaAndData copy = rmad.clone();
} catch (RuntimeException e) {
  Throwable cause = e.getCause(); // KettleValueException
  // fall back to field-by-field copy
}

Prevention

When it happens

Trigger: Calling clone() on a RowMetaAndData whose row contains a value the row metadata cannot clone — e.g. binary value / custom data type inconsistent with its declared ValueMeta, or stale metadata after columns changed.

Common situations: Rows built manually with mismatched metadata vs actual value types, big decimal/date values with unusual converters, cloning rows inside plugin code after modifying rowMeta without adjusting data.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/RowMetaAndData.java:57

  }

  /**
   * @param rowMeta
   * @param data
   */
  public RowMetaAndData( RowMetaInterface rowMeta, Object... data ) {
    this.rowMeta = rowMeta;
    this.data = data;
  }

  @Override
  public RowMetaAndData clone() {
    RowMetaAndData c = new RowMetaAndData();
    c.rowMeta = rowMeta.clone();
    try {
      c.data = rowMeta.cloneRow( data );
    } catch ( KettleValueException e ) {
      throw new RuntimeException( "Problem with clone row detected in RowMetaAndData", e );
    }

    return c;
  }

  @Override
  public String toString() {
    try {
      return rowMeta.getString( data );
    } catch ( KettleValueException e ) {
      return rowMeta.toString() + ", error presenting data: " + e.toString();
    }
  }

  /**
   * @return the data
   */
  public Object[] getData() {

View on GitHub (pinned to f3058517a1)