pentaho/pentaho-kettle · error · RhinoRuntimeError
The function call setVariable requires 3 arguments.
Error message
The function call setVariable requires 3 arguments.
What it means
The JavaScript setVariable() function added by Pentaho's ScriptValuesMod step requires exactly 3 arguments: the value, the variable name, and the scope type string. When Rhino invokes the function with any other argument count, the Java implementation throws this Rhino JavaScriptException to abort the script. It exists because setVariable cannot proceed without a value, name, and scope.
Solutions
- Call setVariable with exactly 3 arguments: value, variableName, and scope ('s','r','p','g').
- Check the scope string is one of 's' (system), 'r' (root), 'p' (parent), 'g' (grand-parent).
- Verify your script targets the ScriptValuesMod step's documented API, not another scripting engine's setVariable.
Example fix
// before
setVariable('MY_VAR');
// after
setVariable('MY_VALUE', 'MY_VAR', 'r'); Defensive patterns
Strategy: validation
Validate before calling
// in script before calling
if (arguments.length !== 3) throw new Error('setVariable(value, name, scope) needs exactly 3 args'); Try / catch
try { setVariable(val, 'MY_VAR', 'r'); } catch (e) { logError('setVariable failed: ' + e.message); } Prevention
- Always pass value, name, scope together in one call.
- Keep the documented 3-arg signature visible in team script templates.
- Lint scripts for setVariable calls with non-3 argument counts.
When it happens
Trigger: Calling setVariable(...) from JS in a Modified Java Script Value step with fewer or more than 3 arguments, e.g. setVariable('myVar') or setVariable('x', 'value', 's', extra).
Common situations: Copy-pasted snippets from older Kettle/PDI versions where setVariable had a different signature; forgetting the scope argument; accidentally passing an extra parameter after refactoring.
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 getVariable requires 2 arguments.
- The function call isDate requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/47b737a5c01c31c2.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1819
inStream.close();
}
} catch ( Exception Signal ) {
// Ignore
}
}
}
private static Bowl getBowl( Scriptable scope ) {
Object scmO = scope.get( "_step_", scope );
ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );
return scm.getTransMeta().getBowl();
}
public static void setVariable( Context actualContext, Scriptable actualObject, Object[] arguments,
Function functionContext ) {
if ( arguments.length != 3 ) {
throw Context.reportRuntimeError( "The function call setVariable requires 3 arguments." );
}
Object stepObject = Context.jsToJava( actualObject.get( "_step_", actualObject ), StepInterface.class );
if ( stepObject instanceof StepInterface ) {
StepInterface step = (StepInterface) stepObject;
Trans trans = step.getTrans();
final String variableName = Context.toString( arguments[ 0 ] );
final String variableValue = Context.toString( arguments[ 1 ] );
final VariableScope variableScope = getVariableScope( Context.toString( arguments[ 2 ] ) );
// Set variable in step's scope so that it can be retrieved in the same step using getVariable
step.setVariable( variableName, variableValue );
switch ( variableScope ) {
case PARENT:
setParentScopeVariable( trans, variableName, variableValue );
break;
case GRAND_PARENT:View on GitHub (pinned to f3058517a1)