pentaho/pentaho-kettle · error · SftpException

Failed to check if path is directory:

Error message

Failed to check if path is directory: 

What it means

MinaSftpSession.isDirectory() wraps any IOException from the SSH client stat() call into an SftpException. It means the remote path could not be stat'ed, so the library cannot tell whether it is a directory. The underlying cause (auth, network, missing file) is in the wrapped cause.

Solutions

  1. Verify the remote path exists with an explicit stat or listFiles call before checking isDirectory
  2. Check user permissions on the remote path and parent directory
  3. Confirm the SSH/SFTP session is still connected; reconnect if it dropped
  4. Inspect the wrapped cause (e.getCause()) for the real SSH error code (e.g. no-such-file, permission-denied)

Example fix

// before
if (session.isDirectory(path)) { session.delete(path); }
// after
try {
  if (session.fileExists(path) && session.isDirectory(path)) { session.delete(path); }
} catch (SftpException e) {
  log.error("stat failed for " + path + ": " + e.getCause(), e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Java: pre-check before acting on the path
boolean exists;
try { session.size(path); exists = true; } catch (SftpException e) { exists = false; }
if (!exists) { return; } // path already gone
// also: if (session.isConnected()) { ... }

Type guard

boolean pathExists(MinaSftpSession s, String p) {
  try { s.size(p); return true; } catch (SftpException e) { return false; }
}

Try / catch

try {
  if (session.isDirectory(path)) { session.delete(path); }
} catch (SftpException e) {
  Throwable cause = e.getCause();
  if (cause instanceof java.nio.file.NoSuchFileException) { /* already gone, ignore */ }
  else throw e;
}

Prevention

When it happens

Trigger: Calling isDirectory(path) when client.stat(path) throws IOException: path does not exist, permission denied on path, SFTP channel dropped, or server returned an error to the STAT request.

Common situations: Typically reached via delete(path) on a remote file that was already removed, a typo in the remote path, an SFTP server that restricts the user to a chroot subdir the path escapes, or a session that died mid-operation.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/core/ssh/mina/MinaSftpSession.java:70

    }
  }

  @Override
  public boolean exists( String path ) throws SftpException {
    try {
      client.stat( path );
      return true;
    } catch ( IOException e ) {
      return false;
    }
  }

  @Override
  public boolean isDirectory( String path ) throws SftpException {
    try {
      return client.stat( path ).isDirectory();
    } catch ( IOException e ) {
      throw new SftpException( "Failed to check if path is directory: " + path, e );
    }
  }

  @Override
  public long size( String path ) throws SftpException {
    try {
      return client.stat( path ).getSize();
    } catch ( IOException e ) {
      throw new SftpException( "Failed to get file size: " + path, e );
    }
  }

  @Override
  public void download( String remote, OutputStream target ) throws SftpException {
    try {
      try ( InputStream in = client.read( remote ) ) {
        in.transferTo( target );
      }

View on GitHub (pinned to f3058517a1)