{"record":{"id":"f10e3a0224b8a6a8","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotsourceattachedwildcard","errorCode":null,"errorMessage":"Mail.Exception.CouldnotSourceAttachedWildcard","messagePattern":"Mail\\.Exception\\.CouldnotSourceAttachedWildcard","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":529,"sourceCode":"    if ( meta.isDynamicFilename() ) {\n      // cache the position of the attached source filename field\n      cacheSourceFileNameField();\n      // cache the position of the attached wildcard field\n      cacheWildCardField();\n    } else {\n      // static attached filenames\n      data.realSourceFileFoldername = environmentSubstitute( meta.getSourceFileFoldername() );\n      data.realSourceWildcard = environmentSubstitute( meta.getSourceWildcard() );\n    }\n  }\n\n  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,","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L511-L547","documentation":"Thrown by Mail.cacheWildCardField when a dynamic wildcard field name is configured (meta.getDynamicWildcard()) but that field cannot be found in the incoming row: data.previousRowMeta.indexOfValue(name) returns -1. Unlike the empty-field checks, the name is present in config but does not match any column of the row arriving at the step, typically due to a typo, renamed field, or an upstream step that no longer produces the column.","triggerScenarios":"The wildcard field selected in the Mail step does not exist in the rowset at execution time; an upstream step (e.g. a filter or select-values) renamed/dropped the column; case mismatch between configured name and actual field name; processAttachedFiles runs before the first row populates previousRowMeta correctly.","commonSituations":"Refactoring upstream transformations without updating the Mail step's field references; locale/case discrepancies between environments; dynamic wildcard option enabled while the hop delivers rows without that column.","solutions":["Verify the exact field name in the Mail step's wildcard-field setting matches an incoming column (case-sensitive).","Add the column upstream (e.g. via Select Values or a User Defined Java Expression) so the wildcard reaches the Mail step.","Re-open and re-save the Mail step after upstream changes so field indices refresh.","Log data.previousRowMeta.getFieldNames() before the step to inspect actual available columns."],"exampleFix":"// upstream: ensure the column exists before the Mail step\n// before\nString field = data.previousRowMeta.indexOfValue(\"wildcard\") >= 0 ? \"wildcard\" : data.previousRowMeta.getFieldNames()[0];\n// after — fix the configuration to a real column name\n// Mail step dialog: wildcard field = \"fileWildcard\" (exists in row) instead of \"wildcard\"\nString configured = meta.getDynamicWildcard(); // \"fileWildcard\"\nint idx = data.previousRowMeta.indexOfValue(configured); // >= 0","handlingStrategy":"validation","validationCode":"// Before the Mail step, verify the wildcard field exists in the row\nint idx = rowMeta.indexOfValue( configuredWildcardField );\nif ( idx < 0 ) {\n  throw new IllegalArgumentException(\"Wildcard field '\" + configuredWildcardField + \"' not in row: \"\n    + Arrays.toString( rowMeta.getFieldNames() ) );\n}","typeGuard":null,"tryCatchPattern":"try { transformation.execute(); } catch ( KettleException e ) { if ( e.getMessage().contains(\"CouldnotSourceAttachedWildcard\") ) { /* compare configured name to rowMeta field names and fix reference */ } else { throw e; } }","preventionTips":["After renaming upstream fields, always re-open dependent Mail steps","Use case-exact field names; Kettle field lookup is case-sensitive","Insert a 'Select Values' step to guarantee required columns reach the Mail step"],"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"}