pentaho/pentaho-kettle · error · RhinoRuntimeError
The function call getVariable requires 2 arguments.
Error message
The function call getVariable requires 2 arguments.
What it means
The JS getVariable() function requires exactly 2 arguments: the variable name and the scope type string. If the argument count differs, the implementation throws this Rhino runtime error instead of returning a value. The two-part signature lets getVariable know both what to read and from which scope.
Solutions
- Call getVariable with exactly 2 arguments: variable name and scope ('s','r','p','g').
- If the variable may be missing, wrap the call or supply a default in your script.
- Confirm you are not conflating getVariable with Java-side getVariable methods.
Example fix
// before
var v = getVariable('MY_VAR');
// after
var v = getVariable('MY_VAR', 'r'); Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 2) throw new Error('getVariable(name, scope) needs exactly 2 args'); Try / catch
try { v = getVariable(name, 'r'); } catch (e) { v = defaultValue; } Prevention
- Always supply the scope letter as the second argument.
- Wrap getVariable in a helper that provides a default value.
- Review one-argument getVariable calls when porting old scripts.
When it happens
Trigger: getVariable('MY_VAR') with no scope argument, or getVariable('A','r','extra') with an extra argument, in a Modified Java Script Value step.
Common situations: Porting scripts from JavaScript engines where getVariable took one argument; forgetting the scope letter; calling with zero arguments when the variable name was built dynamically.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- The function call decode requires more than 1 argument.
- The function call getInputRowMeta doesn't require arguments.
- The function call getOutputRowMeta doesn't require…
- The function call isDate requires 1 argument.
- The function call isNum requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/912b4df1be0225bc.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1939
Object scmo = actualObject.get( "_step_", actualObject );
Object scmO = Context.jsToJava( scmo, StepInterface.class );
if ( scmO instanceof StepInterface ) {
StepInterface scm = (StepInterface) Context.jsToJava( scmO, StepInterface.class );
sArg1 = Context.toString( ArgList[0] );
sArg2 = Context.toString( ArgList[1] );
return scm.getVariable( sArg1, sArg2 );
} else {
// running via the Test button in a dialog
sArg2 = Context.toString( ArgList[1] );
return sArg2;
}
} catch ( Exception e ) {
sRC = "";
}
} else {
throw Context.reportRuntimeError( "The function call getVariable requires 2 arguments." );
}
return sRC;
}
// Return the output row metadata
public static RowMetaInterface getOutputRowMeta( Context actualContext, Scriptable actualObject,
Object[] ArgList, Function FunctionContext ) {
if ( ArgList.length == 0 ) {
try {
Object scmO = actualObject.get( "_step_", actualObject );
try {
ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );
return scm.getOutputRowMeta();
} catch ( Exception e ) {
ScriptValuesModDummy scm = (ScriptValuesModDummy) Context.jsToJava( scmO, ScriptValuesModDummy.class );
return scm.getOutputRowMeta();
}
} catch ( Exception e ) {View on GitHub (pinned to f3058517a1)