{"record":{"id":"e66bae53d1aa9a78","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-a-row-copy-scriptvaluesaddedfunctions","errorCode":null,"errorMessage":"Unable to create a row copy: ","messagePattern":"Unable to create a row copy: ","errorType":"exception","errorClass":"RhinoRuntimeError","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2000,"sourceCode":"      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call getInputRowMeta doesn't require arguments.\" );\n    }\n  }\n\n  // Return the input row metadata\n  public static Object[] createRowCopy( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        int newSize = (int) Math.round( Context.toNumber( ArgList[0] ) );\n\n        Object scmO = actualObject.get( \"row\", actualObject );\n        Object[] row = (Object[]) Context.jsToJava( scmO, ( new Object[] {} ).getClass() );\n\n        return RowDataUtil.createResizedCopy( row, newSize );\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"Unable to create a row copy: \" + Const.CR + e.toString() );\n      }\n    } else {\n      throw Context\n        .reportRuntimeError( \"The function call createRowCopy requires a single arguments : the new size of the row\" );\n    }\n  }\n\n  // put a row out to the next steps...\n  //\n  public static void putRow( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        Object[] newRow = (Object[]) Context.jsToJava( ArgList[0], ( new Object[] {} ).getClass() );\n\n        Object scmO = actualObject.get( \"_step_\", actualObject );\n        try {\n          ScriptValuesMod step = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );","sourceCodeStart":1982,"sourceCodeEnd":2018,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1982-L2018","documentation":"createRowCopy(newSize) reads the 'row' scriptable property and converts it to an Object[] to build a resized copy via RowDataUtil.createResizedCopy; any failure (missing row binding, wrong type, null row) is reported as this Rhino runtime error with the exception appended. It indicates the script's current row could not be copied.","triggerScenarios":"Calling createRowCopy(N) when the 'row' variable is not available in the step context, is not an Object[], or the resize operation throws (e.g. negative or invalid size).","commonSituations":"Using createRowCopy in steps that don't expose 'row'; calling it before the first row arrives; passing a non-integer size such as a string.","solutions":["Verify the script runs in a step that exposes the 'row' object (ScriptValuesMod / User Defined Java Class style bindings).","Pass an integer for the new row size, and include fields needed for appended columns.","Check the appended exception (after the message) for the exact cause.","Ensure a row is being processed (call it per-row, not at initialization)."],"exampleFix":"// before\nvar row2 = createRowCopy('5');\n// after\nvar row2 = createRowCopy(5);","handlingStrategy":"try-catch","validationCode":"// validate size before call\nif (typeof newSize !== 'number' || newSize <= 0) throw new Error('createRowCopy needs positive integer size');","typeGuard":null,"tryCatchPattern":"try { var row2 = createRowCopy(5); } catch (e) { logError('createRowCopy failed: ' + e.message); var row2 = null; }","preventionTips":["Use integer sizes only.","Call within per-row processing where 'row' is bound.","Read the appended exception for the actual cause."],"tags":["javascript","row-manipulation","pentaho"],"backgroundTag":"type-mismatch","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"}