pentaho/pentaho-kettle · error · RuntimeException
The function call num2str requires at least 1 argument.
Error message
The function call num2str requires at least 1 argument.
What it means
Thrown by num2str() in the PDI Script step when called with zero arguments; the function converts a numeric value to a string and requires at least the number itself (optional format and locale may follow).
Solutions
- Pass the numeric field: num2str(myNumber).
- Add a format argument if needed: num2str(myNumber, '####.00').
- Check that the variable holding the number is not empty/undeclared in the script scope.
Example fix
// before num2str() // after num2str(amount, '#,##0.00')
Defensive patterns
Strategy: validation
Validate before calling
function safeNum2str(v, fmt) {
if (v === undefined || v === null) return null;
return fmt !== undefined ? num2str(v, fmt) : num2str(v);
} Type guard
function isNumber(v) { return typeof v === 'number' && !isNaN(v); } Try / catch
try { return num2str(v); }
catch (e) { if (/requires at least 1 argument/.test(e.message)) return ''; throw e; } Prevention
- Always supply the numeric argument explicitly by field name.
- Verify variable names in scripts so they do not resolve to empty.
- Add an explicit format string for deterministic output across JVMs.
When it happens
Trigger: num2str() invoked with an empty argument list, typically because the field reference evaluated to nothing or the argument was deleted during editing.
Common situations: A field variable name typo resolving to empty in the script; an edited call that dropped the number; template scripts pasted with placeholder arguments removed.
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 date2str requires 1, 2, 3, or 4 arguments.
- The function call lower requires 1 argument.
- The function call upper requires 1 argument.
- Please provide a valid date to the function call date2str.
- Row.EndOfFileReached
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/79100fc85c2323f4.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1300
}
sRC = (String) ArgList[0];
sRC = sRC.toLowerCase();
} catch ( Exception e ) {
throw new RuntimeException( "The function call lower is not valid : " + e.getMessage() );
}
} else {
throw new RuntimeException( "The function call lower requires 1 argument." );
}
return sRC;
}
// Converts the given Numeric to a JScript String
public static String num2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
String sRC = "";
switch ( ArgList.length ) {
case 0:
throw new RuntimeException( "The function call num2str requires at least 1 argument." );
case 1:
try {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) undefinedValue;
}
double sArg1 = (Double) ArgList[0];
if ( Double.isNaN( sArg1 ) ) {
throw new RuntimeException( "The first Argument must be a Number." );
}
DecimalFormat formatter = new DecimalFormat();
sRC = formatter.format( sArg1 );
} catch ( IllegalArgumentException e ) {
throw new RuntimeException( "Could not apply the given format on the number : " + e.getMessage() );
}
break;
case 2:View on GitHub (pinned to f3058517a1)