{"record":{"id":"33457b9a39fefa52","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-the-input-row-metadata-because-of-an-error","errorCode":null,"errorMessage":"Unable to get the input row metadata because of an error: ","messagePattern":"Unable to get the input row metadata 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":1893,"sourceCode":"      throw new RuntimeException( \"The function call getOutputRowMeta doesn't require arguments.\" );\n    }\n  }\n\n  // Return the input row metadata\n  public static RowMetaInterface getInputRowMeta( ScriptEngine actualContext, Bindings actualObject,\n    Object[] ArgList, Object FunctionContext ) {\n    if ( ArgList.length == 0 ) {\n      try {\n        Object scmO = actualObject.get( \"_step_\" );\n        try {\n          Script scm = (Script) scmO;\n          return scm.getInputRowMeta();\n        } catch ( Exception e ) {\n          ScriptDummy scm = (ScriptDummy) scmO;\n          return scm.getInputRowMeta();\n        }\n      } catch ( Exception e ) {\n        throw new RuntimeException( \"Unable to get the input row metadata because of an error: \"\n          + Const.CR + e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call getInputRowMeta doesn't require arguments.\" );\n    }\n  }\n\n  // Return the input row metadata\n  public static Object[] createRowCopy( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      try {\n        int newSize = (int) Math.round( (Double) ArgList[0] );\n\n        Object scmO = actualObject.get( \"row\" );\n        Object[] row = (Object[]) scmO; // TODO AKRETION ensure\n\n        return RowDataUtil.createResizedCopy( row, newSize );","sourceCodeStart":1875,"sourceCodeEnd":1911,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1875-L1911","documentation":"Thrown by the getInputRowMeta helper function exposed to JavaScript scripts inside the Script transform (ScriptAddedFunctions.java). The script called getInputRowMeta(), and the wrapper failed to read the current input row metadata from the transform's ScriptDummy/step binding, wrapping the underlying exception in a RuntimeException with this message. It indicates the script environment could not supply the incoming row's row metadata (RowMetaInterface).","triggerScenarios":"A script (JavaScript/beanshell via the Script transform) invokes the added function getInputRowMeta() and either (a) the 'scm'/'_step_' bound object does not implement ScriptInterface so its getInputRowMeta() call throws, or (b) the fallback ScriptDummy.getInputRowMeta() throws an unexpected exception.","commonSituations":"Calling getInputRowMeta() in a script step running before the first row arrives (metadata not yet set), using the function in a Script transform variant where the step binding is a plain ScriptDummy without row metadata, or copy-pasting scripts written for one Pentaho/Kettle version into a differently-wired script step.","solutions":["Inspect the wrapped cause printed after the message (Const.CR + e.toString()) and fix the underlying exception it reports.","Ensure the script step has received/derived input row metadata before calling getInputRowMeta(); do not call it before any row flows through the step.","Verify the bound step object is the expected transform type (ScriptInterface/ScriptDummy) and that the script is run by the intended Script transform variant, not a stripped-down one.","If metadata is only needed for field names/types, replace getInputRowMeta() with explicit field access (e.g. row.getFieldNames equivalents) to avoid depending on step state."],"exampleFix":"// before\nvar meta = getInputRowMeta();\nvar fields = meta.getFieldNames();\n// after\nif (metaAvailable()) { // e.g. only call after first row / in compatible step\n  var meta = getInputRowMeta();\n  var fields = meta.getFieldNames();\n} else {\n  var fields = []; // fallback\n}","handlingStrategy":"try-catch","validationCode":"// before relying on it, check the step binding exists\nif (typeof getInputRowMeta !== 'function') throw new Error('getInputRowMeta not available in this step');","typeGuard":"function hasInputRowMeta() { try { return getInputRowMeta() != null; } catch (e) { return false; } }","tryCatchPattern":"try {\n  var meta = getInputRowMeta();\n} catch (e) {\n  if (String(e).indexOf('Unable to get the input row metadata') !== -1) {\n    // fall back to default metadata handling / log & continue\n  } else { throw e; }\n}","preventionTips":["Only call getInputRowMeta() after rows are flowing through the step","Confirm you are in a Script transform variant that exposes added functions","Log the wrapped cause (text after the CR) to diagnose the real failure","Prefer explicit output-field configuration over runtime metadata inspection when possible"],"tags":["pdi","kettle","script","row-metadata","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"}