{"record":{"id":"4db378a626ceda04","repo":"pentaho/pentaho-kettle","slug":"the-argument-type-of-function-call-setvariable-should-either","errorCode":null,"errorMessage":"The argument type of function call setVariable should either be \\\"s\\\", \\\"r\\\", \\\"p\\\", or \\\"g\\\".","messagePattern":"The argument type of function call setVariable should either be \\\\\"s\\\\\", \\\\\"r\\\\\", \\\\\"p\\\\\", or \\\\\"g\\\\\"\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":1811,"sourceCode":"\n            VariableSpace parentSpace = scm.getParentVariableSpace();\n            if ( parentSpace != null ) {\n              parentSpace.setVariable( sArg1, sArg2 );\n            }\n          } else if ( \"g\".equals( sArg3 ) ) {\n            // Upto the grand parent\n            scm.setVariable( sArg1, sArg2 );\n\n            VariableSpace parentSpace = scm.getParentVariableSpace();\n            if ( parentSpace != null ) {\n              parentSpace.setVariable( sArg1, sArg2 );\n              VariableSpace grandParentSpace = parentSpace.getParentVariableSpace();\n              if ( grandParentSpace != null ) {\n                grandParentSpace.setVariable( sArg1, sArg2 );\n              }\n            }\n          } else {\n            throw new RuntimeException(\n              \"The argument type of function call setVariable should either be \\\"s\\\", \\\"r\\\", \\\"p\\\", or \\\"g\\\".\" );\n          }\n        }\n\n        // Else: Ignore for now... if we're executing via the Test Button\n\n      } catch ( Exception e ) {\n        throw new RuntimeException( e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call setVariable requires 3 arguments.\" );\n    }\n  }\n\n  // Returning EnvironmentVar\n  public static String getVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    String sRC = \"\";","sourceCodeStart":1793,"sourceCodeEnd":1829,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1793-L1829","documentation":"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.","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1811 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass \"s\", \"r\", \"p\", or \"g\" as the third argument to setVariable","Check for typos, casing, or quotes around the scope string in the script"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}