pentaho/pentaho-kettle · error · RuntimeException

The function call getParentFoldername throw an error : +…

Error message

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

What it means

getParentFoldername() wraps any IOException from VFS resolution or from file.getParent() into this RuntimeException, appending e.toString(). The argument was syntactically acceptable but the VFS layer failed to resolve or query it.

Solutions

  1. Inspect the appended IOException text for the root cause.
  2. Convert the path to a proper URI (forward slashes, escaped spaces) or use file:/// scheme.
  3. Install the needed VFS plugin for the scheme; verify remote credentials/connectivity.
  4. Add retry logic around the transformation or step for transient network errors.
  5. Fall back to pure-JS string manipulation (substring(0, lastIndexOf('/'))) when only the path string is needed.

Example fix

// before
var dir = getParentFoldername( 'sftp://user:pw@host/path/file.txt' ); // IOException if unreachable
// after
try {
  var dir = getParentFoldername( 'sftp://user:pw@host/path/file.txt' );
} catch (e) {
  var dir = filename.substring( 0, filename.lastIndexOf('/') );
}
Defensive patterns

Strategy: try-catch

Validate 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 dir = getParentFoldername(path); } catch (e) { Logger.logError('getParentFoldername IO failure: ' + e); var dir = String(path).substring(0, String(path).lastIndexOf('/')); }

Prevention

When it happens

Trigger: Malformed VFS URI (bad scheme, unescaped characters); file.getParent() throwing IOException on some providers; remote VFS (SFTP/S3) unreachable or credentials failing mid-run.

Common situations: Windows backslash paths parsed as URI scheme; missing commons-vfs provider for a custom scheme; transient network failures during long-running transformations.

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

Appendix: source

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

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

        try {
          // Source file
          file = KettleVFS.getInstance( bowl ).getFileObject( (String) ArgList[0] );
          String foldername = null;
          if ( file.exists() ) {
            foldername = KettleVFS.getFilename( file.getParent() );

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

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

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

View on GitHub (pinned to f3058517a1)