{"record":{"id":"920788a0200ae320","repo":"pentaho/pentaho-kettle","slug":"is-not-a-file","errorCode":null,"errorMessage":"] is not a file!","messagePattern":"\\] is not a file!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":2099,"sourceCode":"\n  public static double getFileSize( 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 0;\n        }\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 {","sourceCodeStart":2081,"sourceCodeEnd":2117,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L2081-L2117","documentation":"Thrown by ScriptAddedFunctions.getFileSize when the resolved VFS object exists but its type is not FileType.FILE (e.g. it is a folder). getFileSize only computes the content size of regular files, so a non-file path is rejected with this RuntimeException.","triggerScenarios":"Calling getFileSize('/some/folder') where the path exists in the VFS but resolves to a directory rather than a regular file.","commonSituations":"Pointing getFileSize at a directory by mistake, a variable/field containing a folder path, or a symlink resolving to a directory.","solutions":["Pass the path of a regular file, not a directory: getFileSize('/data/file.csv').","Check the field/variable holding the path for a trailing folder segment or wrong value.","If you need directory sizes, compute them outside this function (e.g. a UDJC step or Java code)."],"exampleFix":"// before\n var size = getFileSize('/data/reports');\n// after\n var size = getFileSize('/data/reports/2026-09.csv');","handlingStrategy":"validation","validationCode":"var f = new java.io.File(path);\nif (f.exists() && f.isFile()) {\n  var size = getFileSize(path);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass directory paths to getFileSize.","Log the resolved path when building it from variables/fields."],"tags":["kettle","javascript-step","vfs","not-a-file"],"backgroundTag":"invalid-argument-value","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"}