pentaho/pentaho-kettle · error · KettleException

Mail.Exception.CouldnotSourceAttachedZipFilenameField

Error message

Mail.Exception.CouldnotSourceAttachedZipFilenameField

What it means

The Mail step is configured to attach a zip file whose path comes from a dynamic field, but the configured dynamic zip filename field was not found in the incoming row. cacheFieldsPosition throws this KettleException when the indexOfValue lookup returns -1.

Solutions

  1. Verify the dynamic zip filename field name matches a field in the input stream exactly.
  2. Preview upstream rows to confirm the zip filename field reaches the Mail step.
  3. If the zip path is fixed, disable 'Dynamic zip filename' and set the path statically.

Example fix

// before
// dynamicZipFilenameField = "zip_path" but stream field is "archive_path"
// after
// meta.setDynamicZipFilenameField("archive_path");
Defensive patterns

Strategy: validation

Validate before calling

if (meta.isZipFilenameDynamic()
    && meta.getDynamicZipFilenameField() != null && !meta.getDynamicZipFilenameField().isEmpty()
    && rowMeta.indexOfValue(meta.getDynamicZipFilenameField()) < 0) {
  throw new KettleException("Dynamic zip filename field not found: " + meta.getDynamicZipFilenameField());
}

Try / catch

try { sendMail(); } catch (KettleException e) { if (e.getMessage().contains("CouldnotSourceAttachedZipFilenameField")) { logError("Dynamic zip filename field does not exist in the input stream"); } throw e; }

Prevention

When it happens

Trigger: meta.isZipFilenameDynamic() is true, meta.getDynamicZipFilenameField() is non-empty, and data.previousRowMeta.indexOfValue(realZipFilename) < 0.

Common situations: Typo in the zip filename field; upstream step producing the zip path removed or renamed; enabling 'dynamic zip filename' without wiring a producing step.

Related errors


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

Appendix: source

Thrown at plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java:441

        // Empty Field
        throw new KettleException( BaseMessages.getString(
          PKG, "Mail.Exception.AttachedContentFileNameFieldEmpty" ) );
      }
      data.IndexOfAttachedFilename = data.previousRowMeta.indexOfValue( attachedContentFileNameField );
      if ( data.IndexOfAttachedFilename < 0 ) {
        throw new KettleException( BaseMessages.getString(
          PKG, "Mail.Exception.CouldnotFindAttachedContentFileNameField", attachedContentFileNameField ) );
      }
    } else {

      // Dynamic Zipfilename
      if ( meta.isZipFilenameDynamic() ) {
        // cache the position of the attached source filename field
        if ( data.indexOfDynamicZipFilename < 0 ) {
          String realZipFilename = meta.getDynamicZipFilenameField();
          data.indexOfDynamicZipFilename = data.previousRowMeta.indexOfValue( realZipFilename );
          if ( data.indexOfDynamicZipFilename < 0 ) {
            throw new KettleException( BaseMessages.getString(
              PKG, "Mail.Exception.CouldnotSourceAttachedZipFilenameField", realZipFilename ) );
          }
        }
      }
      data.zipFileLimit = Const.toLong( environmentSubstitute( meta.getZipLimitSize() ), 0 );
      if ( data.zipFileLimit > 0 ) {
        data.zipFileLimit = data.zipFileLimit * 1048576; // Mo
      }

      if ( !meta.isZipFilenameDynamic() ) {
        data.ZipFilename = environmentSubstitute( meta.getZipFilename() );
      }
      // Attached files
      processAttachedFiles();
    }
  }

  @VisibleForTesting

View on GitHub (pinned to f3058517a1)