{"record":{"id":"ff791c6b9abfdc21","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotsourceattachedzipfilenamefield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotSourceAttachedZipFilenameField","messagePattern":"Mail\\.Exception\\.CouldnotSourceAttachedZipFilenameField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":441,"sourceCode":"        // Empty Field\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.AttachedContentFileNameFieldEmpty\" ) );\n      }\n      data.IndexOfAttachedFilename = data.previousRowMeta.indexOfValue( attachedContentFileNameField );\n      if ( data.IndexOfAttachedFilename < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindAttachedContentFileNameField\", attachedContentFileNameField ) );\n      }\n    } else {\n\n      // Dynamic Zipfilename\n      if ( meta.isZipFilenameDynamic() ) {\n        // cache the position of the attached source filename field\n        if ( data.indexOfDynamicZipFilename < 0 ) {\n          String realZipFilename = meta.getDynamicZipFilenameField();\n          data.indexOfDynamicZipFilename = data.previousRowMeta.indexOfValue( realZipFilename );\n          if ( data.indexOfDynamicZipFilename < 0 ) {\n            throw new KettleException( BaseMessages.getString(\n              PKG, \"Mail.Exception.CouldnotSourceAttachedZipFilenameField\", realZipFilename ) );\n          }\n        }\n      }\n      data.zipFileLimit = Const.toLong( environmentSubstitute( meta.getZipLimitSize() ), 0 );\n      if ( data.zipFileLimit > 0 ) {\n        data.zipFileLimit = data.zipFileLimit * 1048576; // Mo\n      }\n\n      if ( !meta.isZipFilenameDynamic() ) {\n        data.ZipFilename = environmentSubstitute( meta.getZipFilename() );\n      }\n      // Attached files\n      processAttachedFiles();\n    }\n  }\n\n  @VisibleForTesting","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L423-L459","documentation":"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.","triggerScenarios":"meta.isZipFilenameDynamic() is true, meta.getDynamicZipFilenameField() is non-empty, and data.previousRowMeta.indexOfValue(realZipFilename) < 0.","commonSituations":"Typo in the zip filename field; upstream step producing the zip path removed or renamed; enabling 'dynamic zip filename' without wiring a producing step.","solutions":["Verify the dynamic zip filename field name matches a field in the input stream exactly.","Preview upstream rows to confirm the zip filename field reaches the Mail step.","If the zip path is fixed, disable 'Dynamic zip filename' and set the path statically."],"exampleFix":"// before\n// dynamicZipFilenameField = \"zip_path\" but stream field is \"archive_path\"\n// after\n// meta.setDynamicZipFilenameField(\"archive_path\");","handlingStrategy":"validation","validationCode":"if (meta.isZipFilenameDynamic()\n    && meta.getDynamicZipFilenameField() != null && !meta.getDynamicZipFilenameField().isEmpty()\n    && rowMeta.indexOfValue(meta.getDynamicZipFilenameField()) < 0) {\n  throw new KettleException(\"Dynamic zip filename field not found: \" + meta.getDynamicZipFilenameField());\n}","typeGuard":null,"tryCatchPattern":"try { sendMail(); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotSourceAttachedZipFilenameField\")) { logError(\"Dynamic zip filename field does not exist in the input stream\"); } throw e; }","preventionTips":["Wire an upstream step that generates the zip filename field before enabling dynamic zip filename.","Verify the field with a preview after any upstream change.","Use a static zip path when the filename does not actually vary per row."],"tags":["kettle","pentaho","mail-step","attachments"],"backgroundTag":"field-not-found-in-row","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}