pentaho/pentaho-kettle · error

The function call getFileExtension throw an error :

Error message

The function call getFileExtension throw an error : 

What it means

getFileExtension() returns the extension of the file given as its argument, resolved through KettleVFS. When a java.io.IOException occurs during VFS resolution or name parsing, the function rethrows it as a JavaScript runtime error prefixed 'The function call getFileExtension throw an error : '. It signals an I/O failure, not an argument problem.

Solutions

  1. Use a correct, fully-qualified VFS URI with special characters escaped
  2. Check connectivity/credentials to the remote filesystem
  3. Verify the scheme is supported by the deployed commons-vfs providers
  4. Pre-check existence with isFile()/isFolder() to localize the failure

Example fix

// before
var ext = getFileExtension('C:\\data\\report.txt'); // unescaped backslashes on URI parse
// after
var ext = getFileExtension('file:///C:/data/report.txt');
Defensive patterns

Strategy: try-catch

Validate before calling

var f = isFile(path); // resolve failures surface here first

Type guard

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

Try / catch

try { var ext = getFileExtension(path); } catch (e) {
  ext = ''; // VFS IOException — fall back to parsing the string
  ext = path && path.lastIndexOf('.') >= 0 ? path.substring(path.lastIndexOf('.') + 1) : '';
}

Prevention

When it happens

Trigger: IOException from KettleVFS.getFileObject(path) or while inspecting the resolved FileObject — bad URI, unsupported scheme, unreachable remote filesystem, resolution/close I/O failures.

Common situations: Network drives or SFTP servers offline, invalid URI characters in the path, missing commons-vfs provider for the scheme, repository/relative path that cannot be resolved in the environment.

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

Appendix: source

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

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

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

          } else {
            Context.reportRuntimeError( "file [" + Context.toString( ArgList[0] ) + "] can not be found!" );
          }

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

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

View on GitHub (pinned to f3058517a1)