pentaho/pentaho-kettle · error · RhinoRuntimeError

The function call getEnvironmentVar requires 1 argument.

Error message

The function call getEnvironmentVar requires 1 argument.

What it means

Argument-count guard in ScriptValuesAddedFunctions.getEnvironmentVar, which reads a variable (step/kettle environment variable) by name and returns "" if it is unset or on any lookup failure. It fires when the script calls getEnvironmentVar with an argument count other than exactly 1; Rhino raises a runtime error instead of attempting the lookup. Fix by calling getEnvironmentVar with exactly one string argument naming the variable.

Solutions

  1. Call getEnvironmentVar(name) with exactly one argument
  2. Use setEnvironmentVar first if the variable may not exist
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1629 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/bda4aa7edd9fd8bc. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1629

          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] );
            sRC = scm.getVariable( sArg1, "" );
          } else {
            // running in test mode, return ""
            sRC = "";
          }

        }

      } catch ( Exception e ) {
        sRC = "";
      }
    } else {
      throw Context.reportRuntimeError( "The function call getEnvironmentVar requires 1 argument." );
    }
    return sRC;
  }

  public static String trim( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    String sRC = "";
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return (String) Context.getUndefinedValue();
        }
        sRC = Context.toString( ArgList[0] );
        sRC = Const.trim( sRC );
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( "The function call trim is not valid : " + e.getMessage() );

View on GitHub (pinned to f3058517a1)