{"record":{"id":"03732bf7edf9bc9f","repo":"pentaho/pentaho-kettle","slug":"the-function-call-fillstring-requires-2-arguments","errorCode":null,"errorMessage":"The function call fillString requires 2 arguments.","messagePattern":"The function call fillString requires 2 arguments\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":709,"sourceCode":"        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {\n          return (String) undefinedValue;\n        }\n        String fillChar = (String) ArgList[0];\n        int count = (Integer) ArgList[1];\n        if ( fillChar.length() != 1 ) {\n          throw new RuntimeException( \"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 new RuntimeException( e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call fillString requires 2 arguments.\" );\n    }\n  }\n\n  public static Object isCodepage( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object 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 undefinedValue;\n        }\n        String strValueToCheck = (String) ArgList[0];\n        String strCodePage = (String) ArgList[1];\n        byte[] bytearray = strValueToCheck.getBytes();\n        CharsetDecoder d = Charset.forName( strCodePage ).newDecoder();\n        CharBuffer r = d.decode( ByteBuffer.wrap( bytearray ) );","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L691-L727","documentation":"fillString requires exactly two arguments: the single fill character and the repeat count. When ArgList.length != 2 it throws this RuntimeException from the else branch. This check runs before any value validation.","triggerScenarios":"Calling fillString('-') (missing count) or fillString('-', 10, 'x') (extra argument).","commonSituations":"Forgetting the count and expecting a default; porting code from other padding libraries that take (length, char) in the opposite order and dropping one argument.","solutions":["Call with exactly two arguments: fillString(char, count).","Add the missing count argument.","Note the argument order is (char, count), not (count, char)."],"exampleFix":"// before\nvar pad = fillString(20);\n// after\nvar pad = fillString(' ', 20);","handlingStrategy":"validation","validationCode":"if (arguments.length !== 2) {\n  throw new Error('fillString requires exactly 2 arguments: (char, count)');\n}\nvar padded = fillString(fillChar, count);","typeGuard":"function isFillStringCall(c, n) { return typeof c === 'string' && c.length === 1 && typeof n === 'number'; }","tryCatchPattern":"try {\n  var padded = fillString(fillChar, count);\n} catch (e) {\n  if (String(e.message).indexOf('requires 2 arguments') !== -1) {\n    throw new Error('Call fillString as fillString(char, count)');\n  } else { throw e; }\n}","preventionTips":["Argument order is (char, count), not (count, char).","Always supply both arguments explicitly.","Avoid porting padding calls from other libraries without checking this signature."],"tags":["javascript","argument-count","pentaho-kettle"],"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"}