{"record":{"id":"b0332d1c975f649a","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfinddestinationfield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindDestinationField","messagePattern":"Mail\\.Exception\\.CouldnotFindDestinationField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":250,"sourceCode":"        logError( BaseMessages.getString( PKG, \"Mail.Error.AddingImage\", e.getMessage() ) );\n      } finally {\n        if ( image != null ) {\n          try {\n            image.close();\n          } catch ( Exception e ) { /* Ignore */\n          }\n        }\n      }\n    }\n  }\n\n  private void cacheFieldsPosition( MailMeta meta, MailData data ) throws KettleException {\n    // cache the position of the destination field\n    if ( data.indexOfDestination < 0 ) {\n      String realDestinationFieldName = meta.getDestination();\n      data.indexOfDestination = data.previousRowMeta.indexOfValue( realDestinationFieldName );\n      if ( data.indexOfDestination < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindDestinationField\", realDestinationFieldName ) );\n      }\n    }\n\n    // Cc\n    if ( !Utils.isEmpty( meta.getDestinationCc() ) ) {\n      // cache the position of the Cc field\n      if ( data.indexOfDestinationCc < 0 ) {\n        String realDestinationCcFieldname = meta.getDestinationCc();\n        data.indexOfDestinationCc = data.previousRowMeta.indexOfValue( realDestinationCcFieldname );\n        if ( data.indexOfDestinationCc < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindDestinationCcField\", realDestinationCcFieldname ) );\n        }\n      }\n    }\n    // BCc\n    if ( !Utils.isEmpty( meta.getDestinationBCc() ) ) {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L232-L268","documentation":"Thrown by cacheFieldsPosition when the destination (To) field configured in the Mail meta cannot be found in the incoming row's RowMeta. The step needs the recipient address to come from a field in the stream, and indexOfValue returned -1. This fails fast before any mail is sent.","triggerScenarios":"processRow calls cacheFieldsPosition; meta.getDestination() names a field that does not exist in previousRowMeta, so data.indexOfDestination stays -1 after indexOfValue.","commonSituations":"Typo in the destination field name; upstream step renamed or dropped the column; field only appears conditionally upstream; transformation modified after the Mail step was configured.","solutions":["Check the 'Destination fieldname' in the Mail step settings matches an existing incoming column exactly (case-sensitive)","Add a Select Values / Add constants step upstream to guarantee the field exists","Open the step and re-pick the field from the dropdown after changing upstream metadata"],"exampleFix":"// before\nmeta.setDestination(\"dest_adress\");\n// after (matches actual upstream field)\nmeta.setDestination(\"dest_address\");","handlingStrategy":"validation","validationCode":"// before the Mail step, verify the field exists\nif (rowMeta.indexOfValue(\"dest_address\") < 0) {\n  throw new KettleValueException(\"Field dest_address missing from input stream\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindDestinationField\")) {\n    logError(\"Fix the Destination fieldname in the Mail step: \" + e.getMessage());\n  }\n}","preventionTips":["Pick destination fields from the dropdown, never type them","Use a Select Values step to pin the expected columns before Mail","Re-open the Mail step after any upstream schema change"],"tags":["kettle","mail","field-lookup","configuration"],"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"}