pentaho/pentaho-kettle · error · RuntimeException

] is not a file!

Error message

] is not a file!

What it means

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.

Solutions

  1. Pass the path of a regular file, not a directory: getFileSize('/data/file.csv').
  2. Check the field/variable holding the path for a trailing folder segment or wrong value.
  3. If you need directory sizes, compute them outside this function (e.g. a UDJC step or Java code).

Example fix

// before
 var size = getFileSize('/data/reports');
// after
 var size = getFileSize('/data/reports/2026-09.csv');
Defensive patterns

Strategy: validation

Validate before calling

var f = new java.io.File(path);
if (f.exists() && f.isFile()) {
  var size = getFileSize(path);
}

Prevention

When it happens

Trigger: Calling getFileSize('/some/folder') where the path exists in the VFS but resolves to a directory rather than a regular file.

Common situations: Pointing getFileSize at a directory by mistake, a variable/field containing a folder path, or a symlink resolving to a directory.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/920788a0200ae320. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:2099

  public static double getFileSize( Bowl bowl, ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    try {
      if ( ArgList.length == 1 && !isNull( ArgList[0] ) && !isUndefined( ArgList[0] ) ) {
        if ( ArgList[0].equals( null ) ) {
          return 0;
        }
        FileObject file = null;

        try {
          // Source file
          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
          long filesize = 0;
          if ( file.exists() ) {
            if ( file.getType().equals( FileType.FILE ) ) {
              filesize = file.getContent().getSize();
            } else {
              throw new RuntimeException( "[" + ArgList[0] + "] is not a file!" );
            }
          } else {
            throw new RuntimeException( "file [" + ArgList[0] + "] can not be found!" );
          }
          return filesize;
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call getFileSize throw an error : " + e.toString() );
        } finally {
          if ( file != null ) {
            try {
              file.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

      } else {

View on GitHub (pinned to f3058517a1)