pentaho/pentaho-kettle · error · KettleException

PGPEncryptStream.Error.KeyNameMissing

Error message

PGPEncryptStream.Error.KeyNameMissing

What it means

PGPEncryptStream.processRow throws KettleException when a static (non-field) key name is expected but the configured key name (after environment substitution) is empty. The step needs a PGP recipient key name to encrypt.

Solutions

  1. Set the key name in the step dialog (the user ID of the recipient's PGP key)
  2. If using a variable like ${PGP_KEY_NAME}, define it in kettle.properties or the environment configuration
  3. Check for typos/whitespace-only values in the key name

Example fix

// before
export RUN without PGP_KEY set; step uses ${PGP_KEY}
// after
export PGP_KEY="user@example.com"
Defensive patterns

Strategy: validation

Validate before calling

String keyName = meta.getKeyName();
keyName = (keyName == null) ? null : transMeta.environmentSubstitute(keyName).trim();
if (!meta.isKeynameInField() && (keyName == null || keyName.isEmpty())) {
  throw new IllegalStateException("PGP step: static key name (or its variable) is not set");
}

Try / catch

try { trans.execute(null); }
catch (KettleException e) {
  if (e.getMessage().contains("KeyNameMissing")) {
    log.error("PGP key name empty — set it or define the referenced variable", e);
  } else { throw e; }
}

Prevention

When it happens

Trigger: meta.isKeynameInField() is false and environmentSubstitute(meta.getKeyName()) yields null/empty on the first row.

Common situations: Key name field left blank in the dialog, the referenced environment variable (e.g. ${PGP_KEY}) is undefined in the runtime environment, key name set only with whitespace.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/pgpencryptstream/PGPEncryptStream.java:95

        if ( meta.isKeynameInField() ) {
          // keyname will be extracted from a field
          String keyField = meta.getKeynameFieldName();
          if ( Utils.isEmpty( keyField ) ) {
            throw new KettleException( BaseMessages.getString( PKG, "PGPEncryptStream.Error.KeyNameFieldMissing" ) );
          }
          data.indexOfKeyName = data.previousRowMeta.indexOfValue( keyField );
          if ( data.indexOfKeyName < 0 ) {
            // The field is unreachable !
            throw new KettleException( BaseMessages.getString(
              PKG, "PGPEncryptStream.Exception.CouldnotFindField", meta.getStreamField() ) );
          }
        } else {
          // Check is keyname is provided
          data.keyName = environmentSubstitute( meta.getKeyName() );

          if ( Utils.isEmpty( data.keyName ) ) {
            throw new KettleException( BaseMessages.getString( PKG, "PGPEncryptStream.Error.KeyNameMissing" ) );
          }
        }

        // cache the position of the field
        if ( data.indexOfField < 0 ) {
          data.indexOfField = data.previousRowMeta.indexOfValue( meta.getStreamField() );
          if ( data.indexOfField < 0 ) {
            // The field is unreachable !
            throw new KettleException( BaseMessages.getString(
              PKG, "PGPEncryptStream.Exception.CouldnotFindField", meta.getStreamField() ) );
          }
        }
      } // End If first

      // allocate output row
      Object[] outputRow = RowDataUtil.allocateRowData( data.outputRowMeta.size() );
      for ( int i = 0; i < data.NrPrevFields; i++ ) {
        outputRow[i] = r[i];

View on GitHub (pinned to f3058517a1)