pentaho/pentaho-kettle · error · RuntimeException
The function call str2RegExp requires 2 arguments.
Error message
The function call str2RegExp requires 2 arguments.
What it means
str2RegExp() requires exactly two arguments (the string and the regular expression). When ArgList.length != 2 the function throws this RuntimeException instead of attempting a match. It is an arity guard thrown before any regex work happens.
Solutions
- Call str2RegExp with exactly two arguments: str2RegExp(inputString, regexPattern).
- If the regex may be empty conditionally, guard the call in script code before invoking.
- Check the script step log for which call site passes the wrong number of arguments.
Example fix
// before var groups = str2RegExp(value); // after var groups = str2RegExp(value, "(\w+)-(\d+)");
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 2) throw new RuntimeException('str2RegExp requires exactly 2 arguments'); Try / catch
try { var g = str2RegExp(s, rx); } catch (e) { if (String(e.message).indexOf('requires 2 arguments') >= 0) { logError('call-site arity bug'); } } Prevention
- Always call str2RegExp with both string and pattern
- Avoid building argument lists dynamically
- Review scripts after refactoring field names
When it happens
Trigger: Calling str2RegExp with 0, 1, or 3+ arguments in a Modified Java Script Value step, e.g. str2RegExp(myField) forgetting the pattern argument.
Common situations: Copy-pasted script snippets where an argument was dropped; dynamic argument lists built in JavaScript whose length varies; refactorings that removed the pattern parameter.
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
- Please provide a valid date to the function call date2str.
- Please provide a valid string to the function call str2date.
- Row.EndOfFileReached
- Row.EndOfFileReadingRow
- Row.ErrorWritingRow
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/37027f10ed8f1c59.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:946
if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
return undefinedValue;
}
String strToMatch = (String) ArgList[0];
Pattern p = Pattern.compile( (String) ArgList[1] );
Matcher m = p.matcher( strToMatch );
if ( m.matches() && m.groupCount() > 0 ) {
strArr = new String[m.groupCount()];
for ( int i = 1; i <= m.groupCount(); i++ ) {
strArr[i - 1] = m.group( i );
}
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call str2RegExp requires 2 arguments." );
}
return strArr;
}
public static void touch( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
File file = new File( (String) ArgList[0] );
boolean success = file.createNewFile();
if ( !success ) {
file.setLastModified( System.currentTimeMillis() );
}
} else {
throw new RuntimeException( "The function call touch requires 1 valid argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );View on GitHub (pinned to f3058517a1)