{"record":{"id":"5b60d106100f084f","repo":"pentaho/pentaho-kettle","slug":"the-function-call-fillstring-requires-2-arguments-5b60d1","errorCode":null,"errorMessage":"The function call fillString requires 2 arguments.","messagePattern":"The function call fillString requires 2 arguments\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":739,"sourceCode":"        } 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;\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 Context.getUndefinedValue();\n        }\n        String strValueToCheck = Context.toString( ArgList[0] );\n        String strCodePage = Context.toString( ArgList[1] );\n        byte[] bytearray = strValueToCheck.getBytes();\n        CharsetDecoder d = Charset.forName( strCodePage ).newDecoder();\n        CharBuffer r = d.decode( ByteBuffer.wrap( bytearray ) );","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L721-L757","documentation":"Arity guard for fillString: the function builds a repeated-character string from exactly two arguments (fill char, count). With any other count the else-branch throws; note the fill char must also be exactly one character long or a separate error is raised.","triggerScenarios":"Calling fillString('-') (missing count), fillString() or fillString('-', 10, 'x') (extra arg).","commonSituations":"Forgetting the length parameter when building padding; confusing fillString with padLeft/padRight signatures used in other libraries.","solutions":["Call with exactly two arguments: fillString(char, count)","Verify the count argument is not accidentally embedded in the char argument","Use a constant or field value for the count and confirm it is defined"],"exampleFix":"// before\nvar pad = fillString('0');\n// after\nvar pad = fillString('0', 8);","handlingStrategy":"validation","validationCode":"if (arguments.length !== 2) throw new Error('fillString(char, count) requires 2 arguments');","typeGuard":null,"tryCatchPattern":"try { var s = fillString(ch, n); } catch (e) { if (String(e).indexOf('requires 2 arguments') >= 0) { /* correct call */ } }","preventionTips":["Count arguments before calling: char + count = exactly 2","Do not merge the count into the char string","Define defaults (e.g. n = n || 0) outside the call"],"tags":["javascript","kettle","string","argument-count"],"backgroundTag":"missing-required-argument","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"}