{"record":{"id":"11ec7fdd2a8887a8","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getfilesize-is-not-valid","errorCode":null,"errorMessage":"The function call getFileSize is not valid.","messagePattern":"The function call getFileSize is not valid\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2118,"sourceCode":"            }\n          } else {\n            throw new RuntimeException( \"file [\" + ArgList[0] + \"] can not be found!\" );\n          }\n          return filesize;\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"The function call getFileSize throw an error : \" + e.toString() );\n        } finally {\n          if ( file != null ) {\n            try {\n              file.close();\n            } catch ( Exception e ) {\n              // Ignore errors\n            }\n          }\n        }\n\n      } else {\n        throw new RuntimeException( \"The function call getFileSize is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n\n  public static boolean isFile( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    try {\n      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {\n        if ( ArgList[0].equals( null ) ) {\n          return false;\n        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );","sourceCodeStart":2100,"sourceCodeEnd":2136,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2100-L2136","documentation":"Outer validation error thrown by ScriptAddedFunctions.getFileSize when the argument list has an invalid shape. The function expects exactly one argument (the file path); any other count makes the call 'not valid'. The outer catch (Exception e) also rethrows any other failure as e.toString() at the same site.","triggerScenarios":"Calling getFileSize with zero arguments or more than one argument, e.g. getFileSize() or getFileSize(path, extra); the outer catch also surfaces any unexpected exception here as its toString().","commonSituations":"Copy-paste from a two-argument variant, refactorings that added an options parameter not supported by this function, or calling getFileSize with a null first argument.","solutions":["Call getFileSize with exactly one string path argument.","Remove any extra arguments added to the call.","If the message is e.toString() instead, inspect that string for the underlying exception cause."],"exampleFix":"// before\n var size = getFileSize(path, 'bytes');\n// after\n var size = getFileSize(path);","handlingStrategy":"validation","validationCode":"if (typeof path === 'string' && path.length > 0) {\n  var size = getFileSize(path);\n}","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Pass exactly one argument to getFileSize.","Convert fields to strings before passing them."],"tags":["kettle","javascript-step","argument-count","file-size"],"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"}