{"record":{"id":"82d8d041f9e7d89c","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isfile-is-not-valid","errorCode":null,"errorMessage":"The function call isFile is not valid.","messagePattern":"The function call isFile 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":2161,"sourceCode":"            }\n          } else {\n            throw new RuntimeException( \"file [\" + ArgList[0] + \"] can not be found!\" );\n          }\n          return isafile;\n        } catch ( IOException e ) {\n          throw new RuntimeException( \"The function call is File 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 isFile is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw new RuntimeException( e.toString() );\n    }\n  }\n\n  public static boolean isFolder( 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":2143,"sourceCodeEnd":2179,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2143-L2179","documentation":"Thrown by ScriptAddedFunctions.isFile when the argument list does not have the valid shape for the function. isFile expects exactly one argument (the path string); any other count triggers 'The function call isFile is not valid.' The same outer catch also rethrows unrelated exceptions as e.toString() at this site.","triggerScenarios":"Calling isFile() with no arguments, with two or more arguments, or with a null ArgList; the outer catch(Exception) branch also surfaces any other unexpected exception here.","commonSituations":"Refactorings that added a second parameter, dynamic argument arrays that end up empty, or calls copied from other ScriptAddedFunctions variants with different signatures.","solutions":["Call isFile with exactly one string path argument.","Remove extra arguments that this function does not accept.","If the message is e.toString() instead, inspect it for the underlying exception cause."],"exampleFix":"// before\n var ok = isFile(path, throwIfMissing);\n// after\n var ok = isFile(path);","handlingStrategy":"validation","validationCode":"if (typeof path === 'string' && path.length > 0) {\n  var ok = isFile(path);\n}","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Pass exactly one string argument to isFile.","Do not add extra options/flags — the signature accepts only the path.","Wrap the call in try-catch: it throws rather than returning false for missing paths."],"tags":["kettle","javascript-step","argument-count","file-check"],"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"}