pentaho/pentaho-kettle · error · RuntimeException
Please provide a valid Char to the fillString
Error message
Please provide a valid Char to the fillString
What it means
fillString repeats a single character count times to produce a padded string. The first argument must be a string of exactly length 1; if fillChar.length() != 1 the function throws this RuntimeException. It is a value validation on the character argument, distinct from the argument-count check.
Solutions
- Pass exactly one character: fillString('-', 10) or fillString(' ', 10).
- If you need a multi-character pad, use JavaScript repetition instead: new Array(n+1).join(pad).
- Trim or validate the field feeding the argument before the call.
Example fix
// before
var pad = fillString('--', 20);
// after
var pad = fillString('-', 20); Defensive patterns
Strategy: validation
Validate before calling
if (typeof fillChar !== 'string' || fillChar.length !== 1) {
throw new Error('fillString first argument must be a single character');
}
var padded = fillString(fillChar, count); Type guard
function isSingleChar(v) { return typeof v === 'string' && v.length === 1; } Try / catch
try {
var padded = fillString(fillChar, count);
} catch (e) {
if (String(e.message).indexOf('valid Char') !== -1) {
var padded = fillString(String(fillChar).charAt(0), count);
} else { throw e; }
} Prevention
- Always pass a one-character string, never multi-character pads or empty strings.
- For repeated multi-character pads use new Array(n+1).join(pad) in JavaScript instead.
- Validate stream fields for emptiness before using them as the fill character.
When it happens
Trigger: Calling fillString('ab', 5) or fillString('', 5) — any first argument whose string length is not exactly 1 while the argument count itself is correct (2 arguments).
Common situations: Passing multi-character pad strings like '--' or ' ' expecting them to be repeated; passing an empty string because the field was empty in the stream.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The function call initCap requires 1 argument.
- The function call lower is not valid
- The function call ltrim requires 1 argument.
- The function call removeDigits requires 1 argument.
- The function call rtrim requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/51c213d04112b8bf.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:697
}
} else {
throw new RuntimeException( "The function call dateAdd requires 3 arguments." );
}
}
public static String fillString( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
if ( ArgList.length == 2 ) {
try {
if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
return (String) undefinedValue;
}
String fillChar = (String) ArgList[0];
int count = (Integer) ArgList[1];
if ( fillChar.length() != 1 ) {
throw new RuntimeException( "Please provide a valid Char to the fillString" );
} else {
char[] chars = new char[count];
while ( count > 0 ) {
chars[--count] = fillChar.charAt( 0 );
}
return new String( chars );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call fillString requires 2 arguments." );
}
}
public static Object isCodepage( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
boolean bRC = false;View on GitHub (pinned to f3058517a1)