pentaho/pentaho-kettle · error

The function call getFileSize throw an error :

Error message

The function call getFileSize throw an error : 

What it means

getFileSize() throws this when obtaining the file size raises a java.io.IOException; the java exception text is appended to the message. The file existed (the not-found branch was passed) but opening/reading its content or closing the FileObject failed.

Solutions

  1. Read the appended java exception text for the actual IO cause.
  2. Check read permissions on the file.
  3. Try converting to a local file:// URL to rule out VFS provider issues.
  4. If the file is on a network share, verify connectivity and retry.
  5. Wrap the call in try/catch in the JS step and default the size to -1.

Example fix

// before
var size = getFileSize(path);
// after
var size;
try { size = getFileSize(path); } catch (e) { size = -1; }
Defensive patterns

Strategy: try-catch

Validate before calling

var f = new java.io.File(path);
if (!f.exists()) { throw new Error('file missing: ' + path); }
if (!f.canRead()) { throw new Error('not readable: ' + path); }

Try / catch

try { size = getFileSize(path); } catch (e) { size = -1; Logger.logError('getFileSize failed: ' + e.message); }

Prevention

When it happens

Trigger: getFileSize('/path/file') on an existing path where: the FileObject cannot be read (permission), the size lookup triggers content read that fails, the URI points to a stream-like resource, or close() throws and propagates.

Common situations: Special files (device files, named pipes) that fail on read; permission-denied on readable-looking files; flaky network filesystems where metadata access fails.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2195

        }
        FileObject file = null;

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

      } else {
        throw Context.reportRuntimeError( "The function call getFileSize is not valid." );
      }
    } catch ( Exception e ) {
      throw Context.reportRuntimeError( e.toString() );
    }
  }

View on GitHub (pinned to f3058517a1)