pentaho/pentaho-kettle · error · RuntimeException

The function call getFileExtension throw an error : +…

Error message

The function call getFileExtension throw an error :  + e.toString()

What it means

getFileExtension() wraps any IOException raised while resolving or reading the VFS FileObject into a RuntimeException with this message. Unlike the 'can not be found' variant, the file resolution itself failed at the VFS/IO layer (bad URI, provider error, access problem). The original IOException text is appended.

Solutions

  1. Check the appended IOException message (e.getMessage) to identify the underlying cause.
  2. Normalize the path to a forward-slash URI form (file:///C:/data/file.txt on Windows).
  3. Install/verify the VFS provider plugin for remote schemes (S3, SFTP, etc.).
  4. Retry if the cause was a transient network error, after fixing connectivity.
  5. Log the full input argument and surrounding stack trace to confirm which call site threw.

Example fix

// before
var ext = getFileExtension( 'C:\\data\\file.txt' ); // backslashes break VFS URI
// after
var ext = getFileExtension( 'file:///C:/data/file.txt' );
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure URI-safe form before calling
var uri = String(path).replace(/\\/g, '/');
if (/^[A-Za-z]:/.test(uri)) { uri = 'file:///' + uri; }

Type guard

function isUriLike(v){ return typeof v === 'string' && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(v); }

Try / catch

try { var ext = getFileExtension(path); } catch (e) { Logger.logError('getFileExtension IO failure: ' + e); var ext = ''; }

Prevention

When it happens

Trigger: Calling getFileExtension() with a malformed VFS URI (invalid scheme characters), a scheme with no registered VFS provider, or a resolution/exists() check that throws IOException (e.g. network VFS unreachable, permission issues surfacing as IOException).

Common situations: Windows paths with backslashes or drive letters misinterpreted as URI schemes; s3:// or other remote schemes without the required provider plugin installed; network shares temporarily unavailable during the transformation run.

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/a9d0c232fd4954e5. Report an issue: GitHub.

Appendix: source

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

        if ( ArgList[0].equals( null ) ) {
          return null;
        }
        FileObject file = null;

        try {
          // Source file
          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
          String Extension = null;
          if ( file.exists() ) {
            Extension = file.getName().getExtension();

          } else {
            throw new RuntimeException( "file [" + ArgList[0] + "] can not be found!" );
          }

          return Extension;
        } catch ( IOException e ) {
          throw new RuntimeException( "The function call getFileExtension throw an error : " + e.toString() );
        } finally {
          if ( file != null ) {
            try {
              file.close();
            } catch ( Exception e ) {
              // Ignore errors
            }
          }
        }

      } else {
        throw new RuntimeException( "The function call getFileExtension is not valid." );
      }
    } catch ( Exception e ) {
      throw new RuntimeException( e.toString() );
    }
  }

View on GitHub (pinned to f3058517a1)