{"record":{"id":"4e5801777b458c14","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getfilesize-throw-an-error","errorCode":null,"errorMessage":"The function call getFileSize throw an error : ","messagePattern":"The function call getFileSize throw an error : ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2106,"sourceCode":"        }\n        FileObject file = null;\n\n        try {\n          // Source file\n          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );\n          long filesize = 0;\n          if ( file.exists() ) {\n            if ( file.getType().equals( FileType.FILE ) ) {\n              filesize = file.getContent().getSize();\n            } else {\n              throw new RuntimeException( \"[\" + ArgList[0] + \"] is not a file!\" );\n            }\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","sourceCodeStart":2088,"sourceCodeEnd":2124,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2088-L2124","documentation":"Thrown by ScriptAddedFunctions.getFileSize when an IOException occurs while resolving or reading the file through KettleVFS. The original IOException is swallowed and rethrown as a RuntimeException whose message is the string form of the exception, prefixed with 'The function call getFileSize throw an error : '.","triggerScenarios":"KettleVFS.getFileObject or file.getContent() throws IOException: unreadable permission, closed/broken remote connection, malformed VFS URI, or I/O failure while reading content size.","commonSituations":"SFTP/HTTP VFS connection dropped mid-read, malformed URI with special characters, permissions revoked after the path check, or transient network failures on remote filesystems.","solutions":["Read the wrapped exception text after the prefix to identify the real IOException cause.","Check file read permissions and that the VFS URI scheme/credentials are correct.","Retry the transformation if the cause was a transient network failure on a remote filesystem.","Pre-resolve the file with a KettleVFS-compatible path (no unescaped spaces/special characters)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var f = new java.io.File(path);\nif (f.exists() && f.canRead()) {\n  var size = getFileSize(path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  size = getFileSize(path);\n} catch (e) {\n  // message is 'The function call getFileSize throw an error : ' + cause\n  Logger.logError('getFileSize failed: ' + e.message);\n}","preventionTips":["Check read permissions on the file before calling.","Escape special characters in VFS URIs.","Prefer local paths when remote VFS providers are unstable."],"tags":["kettle","javascript-step","io","vfs"],"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"}