{"record":{"id":"51a0a216104948ea","repo":"pentaho/pentaho-kettle","slug":"please-provide-a-valid-char-to-the-fillstring-51a0a2","errorCode":null,"errorMessage":"Please provide a valid Char to the fillString","messagePattern":"Please provide a valid Char to the fillString","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":727,"sourceCode":"      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call dateAdd requires 3 arguments.\" );\n    }\n  }\n\n  public static String fillString( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 2 ) {\n      try {\n        if ( isNull( ArgList, new int[] { 0, 1 } ) ) {\n          return null;\n        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {\n          return (String) Context.getUndefinedValue();\n        }\n        String fillChar = Context.toString( ArgList[0] );\n        int count = (int) Context.toNumber( ArgList[1] );\n        if ( fillChar.length() != 1 ) {\n          throw Context.reportRuntimeError( \"Please provide a valid Char to the fillString\" );\n        } else {\n          char[] chars = new char[count];\n          while ( count > 0 ) {\n            chars[--count] = fillChar.charAt( 0 );\n          }\n          return new String( chars );\n        }\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( e.toString() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call fillString requires 2 arguments.\" );\n    }\n  }\n\n  public static Object isCodepage( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    boolean bRC = false;","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L709-L745","documentation":"fillString repeats a single character N times to produce a padded string in Kettle's JavaScript step. The first argument must be exactly one character; if fillChar.length() != 1 the function throws this RuntimeError instead of silently accepting multi-character or empty input.","triggerScenarios":"Calling fillString('--', 10) or fillString('', 5) - a multi-character or empty string passed as the fill character.","commonSituations":"Users expect fillString to repeat a whole prefix string (like JS String.repeat); passing a two-dash separator or a space plus character from a config field.","solutions":["Pass exactly one character as the first argument: fillString('-', 10)","If you need a multi-character pattern repeated, use a JavaScript loop or Array(count+1).join(str) instead","Trim or slice the input character source before the call"],"exampleFix":"// before\nvar pad = fillString('..', 20);\n// after\nvar pad = fillString('.', 20);","handlingStrategy":"validation","validationCode":"if (typeof ch !== 'string' || ch.length !== 1) throw new Error('fillString needs a single character');\nvar s = fillString(ch, count);","typeGuard":"function isSingleChar(v) { return typeof v === 'string' && v.length === 1; }","tryCatchPattern":"try { var s = fillString(ch, n); } catch (e) { if (String(e).indexOf('valid Char') >= 0) { /* use first char */ } }","preventionTips":["Never pass multi-character pad patterns; slice with .charAt(0) if needed","Remember fillString repeats ONE character only","Use Array(n+1).join(pattern) for multi-character repetition"],"tags":["javascript","kettle","string"],"backgroundTag":"invalid-argument-value","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"}