pentaho/pentaho-kettle · error · RuntimeException

Unable to create a row copy:

Error message

Unable to create a row copy: 

What it means

Thrown by the createRowCopy added function exposed to Script transform scripts. After reading the 'row' variable from the script bindings and resizing it via RowDataUtil.createResizedCopy, any failure (bad row binding, cast failure, resize error) is wrapped in a RuntimeException with this message.

Solutions

  1. Check the wrapped cause (text after Const.CR) — a ClassCastException means the bound 'row' is not Object[]; fix the script/step context.
  2. Ensure createRowCopy is only called while processing an actual incoming row so 'row' is populated.
  3. Pass a single positive integer as the new row size.
  4. If you only need to append fields, use the script transform's normal output-field mechanism instead of manually resizing the row.

Example fix

// before
var newRow = createRowCopy(rowSizeFromVariable);
// after
var newRow = createRowCopy(3); // exact integer size required
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeof row === 'undefined' || row === null) throw new Error('row binding not available');
if (typeof newSize !== 'number' || newSize <= 0) throw new Error('createRowCopy needs a positive integer size');

Type guard

function isObjectArray(x) { return x != null && Object.prototype.toString.call(x) === '[object Array]'; }

Try / catch

try {
  var newRow = createRowCopy(2);
} catch (e) {
  if (String(e).indexOf('Unable to create a row copy') !== -1) {
    // check cause: likely 'row' not Object[] or invalid size
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling createRowCopy(newSize) in a script where (a) the bound 'row' object is not an Object[] (ClassCastException on the cast), (b) 'row' is missing/null, or (c) RowDataUtil.createResizedCopy fails for the requested size.

Common situations: Scripts written for a different step type where 'row' is not bound as Object[], calling createRowCopy before any row exists, or passing a non-integer/new negative size that breaks the resize.

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/0ecd48c4112330bd. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1913

      }
    } else {
      throw new RuntimeException( "The function call getInputRowMeta doesn't require arguments." );
    }
  }

  // Return the input row metadata
  public static Object[] createRowCopy( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        int newSize = (int) Math.round( (Double) ArgList[0] );

        Object scmO = actualObject.get( "row" );
        Object[] row = (Object[]) scmO; // TODO AKRETION ensure

        return RowDataUtil.createResizedCopy( row, newSize );
      } catch ( Exception e ) {
        throw new RuntimeException( "Unable to create a row copy: " + Const.CR + e.toString() );
      }
    } else {
      throw new RuntimeException(
        "The function call createRowCopy requires a single arguments : the new size of the row" );
    }
  }

  // put a row out to the next steps...
  //
  public static void putRow( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        Object[] newRow = (Object[]) ArgList[0];

        Object scmO = actualObject.get( "_step_" );
        try {
          Script step = (Script) scmO;

View on GitHub (pinned to f3058517a1)