{"record":{"id":"a3adeaba4946d032","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotsourceattachedfilenamefield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotSourceAttachedFilenameField","messagePattern":"Mail\\.Exception\\.CouldnotSourceAttachedFilenameField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":541,"sourceCode":"  private void cacheWildCardField() throws KettleException {\n    if ( !Utils.isEmpty( meta.getDynamicWildcard() ) ) {\n      if ( data.indexOfSourceWildcard < 0 ) {\n        String realSourceAttachedWildcard = meta.getDynamicWildcard();\n        data.indexOfSourceWildcard = data.previousRowMeta.indexOfValue( realSourceAttachedWildcard );\n        if ( data.indexOfSourceWildcard < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotSourceAttachedWildcard\", realSourceAttachedWildcard ) );\n        }\n      }\n    }\n  }\n\n  private void cacheSourceFileNameField() throws KettleException {\n    if ( data.indexOfSourceFilename < 0 ) {\n      String realSourceAttachedFilename = meta.getDynamicFieldname();\n      data.indexOfSourceFilename = data.previousRowMeta.indexOfValue( realSourceAttachedFilename );\n      if ( data.indexOfSourceFilename < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotSourceAttachedFilenameField\", realSourceAttachedFilename ) );\n      }\n    }\n  }\n\n  public void sendMail( Object[] r, String server, int port, String senderAddress, String senderName,\n    String destination, String destinationCc, String destinationBCc, String contactPerson, String contactPhone,\n    String authenticationUser, String authenticationPassword, String mailSubject, String comment,\n    String replyToAddresses ) throws Exception {\n\n    // Send an e-mail...\n    // create some properties and get the default Session\n\n    String protocol = \"smtp\";\n    if ( meta.isUsingSecureAuthentication() ) { // PDI-2955\n      // if (meta.isUsingAuthentication()) {\n      if ( meta.getSecureConnectionType().equals( \"TLS\" ) ) {\n        // Allow TLS authentication","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L523-L559","documentation":"Thrown by Mail.cacheSourceFileNameField when the configured dynamic attachment-filename field (meta.getDynamicFieldname()) is not found in the incoming row: previousRowMeta.indexOfValue returns -1. The setting is non-empty (that check is error 3193) but names a column the rowset does not contain, so the step cannot locate attachment paths and aborts.","triggerScenarios":"The dynamic filename field name in MailMeta does not match any column in the row arriving at the Mail step (typo, rename, dropped column upstream, case mismatch); processAttachedFiles triggers field caching on the first processed row.","commonSituations":"Renaming a field in an upstream Text File Input or Table Input step without updating the Mail step; transformations assembled from templates where field names differ; a hop changed so the Mail step now receives rows lacking the attachment column.","solutions":["Correct the dynamic-filename field in the Mail step dialog to an actual incoming column name (exact, case-sensitive).","Ensure the upstream step emits the attachment-path column (add via Select Values if needed).","After upstream schema changes, re-open and re-save the Mail step to refresh field references.","Inspect available columns by logging rowMeta.getFieldNames() immediately before the Mail step."],"exampleFix":"// before\nmeta.setDynamicFieldname(\"attachmentFile\"); // column no longer exists in row\n// after\nmeta.setDynamicFieldname(\"attachment_path\"); // actual incoming column name\nint idx = data.previousRowMeta.indexOfValue(meta.getDynamicFieldname()); // >= 0","handlingStrategy":"validation","validationCode":"// Verify the dynamic attachment filename field exists in the incoming row\nint idx = rowMeta.indexOfValue( meta.getDynamicFieldname() );\nif ( idx < 0 ) {\n  throw new IllegalArgumentException(\"Attachment filename field '\" + meta.getDynamicFieldname() + \"' not in row: \"\n    + Arrays.toString( rowMeta.getFieldNames() ) );\n}","typeGuard":null,"tryCatchPattern":"try { transformation.execute(); } catch ( KettleException e ) { if ( e.getMessage().contains(\"CouldnotSourceAttachedFilenameField\") ) { /* correct meta.setDynamicFieldname to a real column */ } else { throw e; } }","preventionTips":["Keep the dynamic filename field name in sync with upstream schema changes","Log rowMeta.getFieldNames() during development to confirm available columns","Route rows through a Select Values step that explicitly includes the attachment field"],"tags":["kettle","mail-step","row-field","dynamic-fields"],"backgroundTag":"resource-not-found","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"}