pentaho/pentaho-kettle · error · CryptoException

SymmetricCrypto.CanNotFindFile

SymmetricCrypto.CanNotFindFile

Error message

SymmetricCrypto.CanNotFindFile

What it means

setSecretKeyFromFile throws CryptoKeyException with message 'SymmetricCrypto.CanNotFindFile' when the VFS file object for the given filename does not exist. Note the check throws, but the outer catch also wraps other IO failures; this specific message means the key file path did not resolve to an existing file.

Solutions

  1. Verify the key file exists at the exact path (use an absolute path)
  2. Check case sensitivity and platform-specific path separators if moving between OSes
  3. For VFS schemes (sftp/http), confirm connection settings and credentials are configured
  4. Deploy the key file alongside the transformation or use an environment variable for the path

Example fix

// before
String file = "keys/secret.key"; // relative, wrong cwd
symmetricCrypto.setSecretKeyFromFile(bowl, file);
// after
String file = System.getenv("KEY_PATH"); // absolute path
symmetricCrypto.setSecretKeyFromFile(bowl, file);
Defensive patterns

Strategy: validation

Validate before calling

java.io.File f = new java.io.File(filename);
if (!f.isAbsolute() || !f.isFile()) {
  throw new IllegalArgumentException("Key file must be an existing file: " + filename);
}

Try / catch

try { crypto.setSecretKeyFromFile(bowl, filename); } catch (CryptoKeyException e) { log.error("Key file problem: " + e.getMessage(), e); }

Prevention

When it happens

Trigger: Calling setSecretKeyFromFile(bowl, filename) where filename points to a nonexistent path, a directory, or an unmounted/unreachable VFS location (SFTP/HTTP), causing KettleVFS getFileObject + file.exists() to be false.

Common situations: Relative path in the transformation but run from a different working directory; key file deleted or renamed after configuration; SFTP/HTTP VFS credentials not set so file resolution fails; Windows path used on Linux.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/symmetriccrypto/symmetricalgorithm/SymmetricCrypto.java:124

      throw new CryptoKeyException( e );
    }
  }

  public void setSecretKey( byte[] keyBytes ) throws CryptoKeyException {
    try {
      // Convert the raw bytes to a secret key like this
      this.secretKeySpec = new SecretKeySpec( keyBytes, meta.getAlgorithm() );
    } catch ( Exception e ) {
      throw new CryptoKeyException( e );
    }
  }

  public void setSecretKeyFromFile( Bowl bowl, String filename ) throws CryptoKeyException {
    FileObject file = null;
    try {
      file = KettleVFS.getInstance( bowl ).getFileObject( filename );
      if ( !file.exists() ) {
        throw new CryptoException( BaseMessages.getString( PKG, "SymmetricCrypto.CanNotFindFile", file.getName() ) );
      }
      byte[] KeyBytes = new byte[(int) file.getContent().getSize()];

      setSecretKey( KeyBytes );

    } catch ( Exception e ) {
      throw new CryptoKeyException( e );
    } finally {
      if ( file != null ) {
        try {
          file.close();
        } catch ( Exception e ) { /* Ignore */
        }
      }
    }
  }

  public byte[] encrDecryptData( byte[] inpBytes ) throws CryptoException {

View on GitHub (pinned to f3058517a1)