{"record":{"id":"a44969a83b4e2ec2","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isfolder-throw-an-error","errorCode":null,"errorMessage":"The function call isFolder throw an error : ","messagePattern":"The function call isFolder 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":2281,"sourceCode":"        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( getBowl( actualObject ) ).getFileObject( Context.toString( ArgList[0] ) );\n          boolean isafolder = false;\n          if ( file.exists() ) {\n            if ( file.getType().equals( FileType.FOLDER ) ) {\n              isafolder = true;\n            } else {\n              Context.reportRuntimeError( \"[\" + Context.toString( ArgList[0] ) + \"] is not a folder!\" );\n            }\n          } else {\n            Context.reportRuntimeError( \"folder [\" + Context.toString( ArgList[0] ) + \"] can not be found!\" );\n          }\n          return isafolder;\n        } catch ( IOException e ) {\n          throw Context.reportRuntimeError( \"The function call isFolder 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 isFolder is not valid.\" );\n      }\n    } catch ( Exception e ) {\n      throw Context.reportRuntimeError( e.toString() );\n    }\n  }\n","sourceCodeStart":2263,"sourceCodeEnd":2299,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2263-L2299","documentation":"isFolder() resolves its argument via KettleVFS to a FileObject and tests whether it is a folder. If a java.io.IOException occurs while resolving or reading the VFS object (the underlying filesystem layer fails), the function rethrows it as a JavaScript runtime error prefixed 'The function call isFolder throw an error : '. This is an I/O-layer failure, distinct from the argument-validation error of the same function.","triggerScenarios":"KettleVFS.getFileObject(path) or file.exists()/getType() throws IOException — e.g. an unsupported or malformed VFS URI scheme, network filesystem unreachable, permission/lock issues during resolution, or closing errors on the underlying resource.","commonSituations":"Wrong URI scheme (missing sftp://, s3:// prefix) so VFS picks the wrong provider; an SFTP/SMB/network share that is down or unreachable; a path string containing characters that break URI parsing; VFS provider (jsch/commons-vfs) version problems.","solutions":["Verify the path is a valid, fully-qualified VFS URI (correct scheme, escaped special characters)","Check the target filesystem (network share/SFTP server) is reachable and credentials are correct","Run the path through a simpler call like isFile() to isolate whether VFS resolution itself fails","Upgrade/align commons-vfs and provider libraries if the scheme is genuinely supported"],"exampleFix":"// before\nvar isDir = isFolder('/data/ reports');  // space breaks URI parsing\n// after\nvar isDir = isFolder('file:///data/%20reports'); // or sanitize the path","handlingStrategy":"try-catch","validationCode":"// pre-check reachability in script\nvar f = isFile(path); // returns false or throws per type; existence errors surface here","typeGuard":"function isProbablyVfsUri(v) { return typeof v === 'string' && /^[a-z]+:\\/\\//.test(v); }","tryCatchPattern":"try { var d = isFolder(path); } catch (e) {\n  // e contains 'isFolder throw an error : <IOException>' — treat as unavailable\n  d = false; }","preventionTips":["Use fully qualified VFS URIs with correct scheme","Escape spaces/special characters in paths","Verify remote filesystem connectivity/credentials in job setup","Keep commons-vfs and provider libraries up to date"],"tags":["io","vfs","filesystem"],"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"}