{"record":{"id":"f689a629eb30d450","repo":"pentaho/pentaho-kettle","slug":"the-function-call-is-file-throw-an-error","errorCode":null,"errorMessage":"The function call is File throw an error : ","messagePattern":"The function call is File throw an error : ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2238,"sourceCode":"        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );\n          boolean isafile = false;\n          if ( file.exists() ) {\n            if ( file.getType().equals( FileType.FILE ) ) {\n              isafile = true;\n            } else {\n              Context.reportRuntimeError( \"[\" + Context.toString( ArgList[0] ) + \"] is not a file!\" );\n            }\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","sourceCodeStart":2220,"sourceCodeEnd":2256,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2220-L2256","documentation":"isFile() throws this when the file-type check raises a java.io.IOException; the java exception text is appended after the prefix. The path existed (the not-found branch reported it otherwise), but querying whether it is a regular file failed at the VFS layer.","triggerScenarios":"isFile('/path') on an existing resource where determining the type throws: permission issues, unresolvable symbolic link, network filesystem failure, or an exception while closing the FileObject in the finally block.","commonSituations":"Broken symlinks; stale NFS mounts; probing special VFS resources (archives, remote URLs) whose type detection requires I/O that fails.","solutions":["Read the appended java exception text to identify the root cause.","Check permissions and that the path is not a broken symlink.","Prefer a plain local file:// path to test behavior.","If the resource is remote, verify connectivity or cache the check result.","Catch in JS and treat as 'unknown type' rather than failing the transform."],"exampleFix":"// before\nvar ok = isFile(path);\n// after\nvar ok;\ntry { ok = isFile(path); } catch (e) { ok = false; }","handlingStrategy":"try-catch","validationCode":"var f = new java.io.File(path);\nif (!f.exists()) { Logger.logBasic('path missing: ' + path); }","typeGuard":null,"tryCatchPattern":"try { ok = isFile(path); } catch (e) { ok = false; Logger.logError('isFile failed: ' + e.message); }","preventionTips":["Resolve broken symlinks before probing","Verify connectivity for network filesystems","Test with local file:// paths to isolate VFS issues","Treat the appended java exception text as the real diagnostic"],"tags":["javascript","pdi","ioexception","file-type"],"backgroundTag":"file-read-failed","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"}