{"record":{"id":"d11f6ec7b8acab7b","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isfile-is-not-valid-d11f6e","errorCode":null,"errorMessage":"The function call isFile is not valid.","messagePattern":"The function call isFile is not valid\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2250,"sourceCode":"            }\n          } else {\n            Context.reportRuntimeError( \"file [\" + Context.toString( ArgList[0] ) + \"] can not be found!\" );\n          }\n          return isafile;\n        } catch ( IOException e ) {\n          throw Context.reportRuntimeError( \"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 Context.reportRuntimeError( \"The function call isFile is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }\n\n  public static boolean isFolder( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function 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( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );","sourceCodeStart":2232,"sourceCodeEnd":2268,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2232-L2268","documentation":"isFile() is a JavaScript scripting function added by PDI (Kettle)'s ScriptValuesMod step. It resolves its single argument to a VFS FileObject and reports whether it is a regular file. Before doing any I/O it validates the JavaScript argument list; if the call does not have exactly one non-null, non-undefined argument it throws 'The function call isFile is not valid.' via Context.reportRuntimeError, which surfaces as a JavaScript runtime error inside the transform.","triggerScenarios":"Calling isFile() with zero arguments, more than one argument, or with an argument that is JavaScript null or undefined (e.g. a field variable that was never populated). The guard is `ArgList.length == 1 && !isNull(ArgList[0]) && !isUndefined(ArgList[0])`.","commonSituations":"A typo in the variable name inside a JavaScript step (the variable is undefined), a field upstream that did not produce a value, copy-pasted sample code calling isFile with a missing parameter, or passing the result of another function that returned undefined.","solutions":["Ensure isFile is called with exactly one argument, e.g. isFile(filename)","Check the argument variable is defined and not null/undefined before calling (use JS typeof / null checks or a 'If field value is null' step)","Correct upstream field mappings so the filename field is populated","Wrap the call in try/catch inside the script to handle bad input gracefully"],"exampleFix":"// before\nvar ok = isFile();\n// after\nvar path = 'file:///data/input.csv';\nvar ok = isFile(path);","handlingStrategy":"validation","validationCode":"// in the JS step, before calling\nif (typeof myFile === 'undefined' || myFile === null) {\n  throw new Error('myFile must be a non-null path string');\n}\nvar result = isFile(myFile);","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { var ok = isFile(path); } catch (e) { // log and continue row\n  ok = false; }","preventionTips":["Always pass exactly one argument to the VFS helper functions","Null-check fields with a 'If field value is null' step before scripting","Use typeof checks in the script for variables sourced from fields","Keep sample/test data so undefined variables surface early"],"tags":["javascript","argument-count","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"}