{"record":{"id":"408c4b284ebd2f66","repo":"pentaho/pentaho-kettle","slug":"unable-to-pass-the-new-row-to-the-next-step-s-because-of-an","errorCode":null,"errorMessage":"Unable to pass the new row to the next step(s) because of an error: ","messagePattern":"Unable to pass the new row to the next step\\(s\\) because of an error: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":1939,"sourceCode":"  // put a row out to the next steps...\n  //\n  public static void putRow( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        Object[] newRow = (Object[]) ArgList[0];\n\n        Object scmO = actualObject.get( \"_step_\" );\n        try {\n          Script step = (Script) scmO;\n          step.putRow( step.getOutputRowMeta(), newRow );\n        } catch ( Exception e ) {\n          ScriptDummy step = (ScriptDummy) scmO;\n          step.putRow( step.getOutputRowMeta(), newRow );\n        }\n\n      } catch ( Exception e ) {\n        throw new RuntimeException( \"Unable to pass the new row to the next step(s) because of an error: \"\n          + Const.CR + e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call putRow requires 1 argument : the output row data (Object[])\" );\n    }\n  }\n\n  public static void deleteFile( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    try {\n      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {\n        // Object act = actualObject.get(\"_step_\", actualObject);\n        // ScriptValuesMod act = (ScriptValuesMod)Context.toType(scm_delete, ScriptValuesMod.class);\n\n        FileObject fileObject = null;\n\n        try {","sourceCodeStart":1921,"sourceCodeEnd":1957,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1921-L1957","documentation":"Thrown by the putRow added function in ScriptAddedFunctions, which forwards a row to the next transform step(s). After obtaining the step binding and calling putRow(outputRowMeta, newRow), any exception is wrapped in a RuntimeException with this message.","triggerScenarios":"Calling putRow(newRow) in a script when (a) the bound step object's putRow or getOutputRowMeta throws (no output metadata yet, transform not started properly), (b) newRow is not a valid Object[] matching the output row metadata, or (c) the ScriptDummy fallback putRow fails.","commonSituations":"Emitting rows before output row metadata is established, passing a row array whose length/field layout doesn't match the configured output fields, or calling putRow from a script step variant where the step binding doesn't support row output.","solutions":["Read the wrapped cause after the message (e.toString()) to identify the underlying failure (NPE, cast, metadata mismatch).","Ensure putRow is called during row processing, after the step has initialized output row metadata.","Make sure the emitted Object[] matches the output row layout (correct number/order of fields), typically produced via createRowCopy.","If the script should end processing rather than forward a row, use the appropriate abort/stop mechanism instead of putRow."],"exampleFix":"// before\nputRow(someString); // wrong type/layout\n// after\nvar newRow = createRowCopy(2);\nnewRow[1] = someString;\nputRow(newRow);","handlingStrategy":"try-catch","validationCode":"if (typeof row === 'undefined' || row === null) throw new Error('no row to output');\nif (typeof putRow !== 'function') throw new Error('putRow not available in this step');","typeGuard":"function isObjectArray(x) { return x != null && Object.prototype.toString.call(x) === '[object Array]'; }","tryCatchPattern":"try {\n  putRow(newRow);\n} catch (e) {\n  if (String(e).indexOf('Unable to pass the new row') !== -1) {\n    // verify output metadata exists and newRow matches output layout\n  } else { throw e; }\n}","preventionTips":["Emit rows that match the configured output fields (use createRowCopy)","Call putRow only during row processing, not before step init","Read the wrapped cause to distinguish metadata vs data problems","Avoid putRow in script variants where the step cannot forward rows"],"tags":["pdi","kettle","script","putrow","runtime"],"backgroundTag":"invalid-state-transition","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"}