pentaho/pentaho-kettle · error · RuntimeException

The argument type of function call setVariable should…

Error message

The argument type of function call setVariable should either be \"s\", \"r\", \"p\", or \"g\".

What it means

Validation of the third (scope) argument of setVariable in the script step. The variable name/value were accepted, but the scope string was none of "s" (system), "r" (root/job), "p" (parent), or "g" (grand parent); the if/else chain fell through to this guard, so the variable is not written anywhere.

Solutions

  1. Pass "s", "r", "p", or "g" as the third argument to setVariable
  2. Check for typos, casing, or quotes around the scope string in the script
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1811 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/4db378a626ceda04. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1811

            VariableSpace parentSpace = scm.getParentVariableSpace();
            if ( parentSpace != null ) {
              parentSpace.setVariable( sArg1, sArg2 );
            }
          } else if ( "g".equals( sArg3 ) ) {
            // Upto the grand parent
            scm.setVariable( sArg1, sArg2 );

            VariableSpace parentSpace = scm.getParentVariableSpace();
            if ( parentSpace != null ) {
              parentSpace.setVariable( sArg1, sArg2 );
              VariableSpace grandParentSpace = parentSpace.getParentVariableSpace();
              if ( grandParentSpace != null ) {
                grandParentSpace.setVariable( sArg1, sArg2 );
              }
            }
          } else {
            throw new RuntimeException(
              "The argument type of function call setVariable should either be \"s\", \"r\", \"p\", or \"g\"." );
          }
        }

        // Else: Ignore for now... if we're executing via the Test Button

      } catch ( Exception e ) {
        throw new RuntimeException( e.toString() );
      }
    } else {
      throw new RuntimeException( "The function call setVariable requires 3 arguments." );
    }
  }

  // Returning EnvironmentVar
  public static String getVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    String sRC = "";

View on GitHub (pinned to f3058517a1)