{"record":{"id":"a4ced6a7467dfad4","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfindcontactphonefield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindContactPhoneField","messagePattern":"Mail\\.Exception\\.CouldnotFindContactPhoneField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":334,"sourceCode":"    if ( !Utils.isEmpty( meta.getContactPerson() ) ) {\n      // cache the position of the destination field\n      if ( data.indexOfContactPerson < 0 ) {\n        String realContactPerson = meta.getContactPerson();\n        data.indexOfContactPerson = data.previousRowMeta.indexOfValue( realContactPerson );\n        if ( data.indexOfContactPerson < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindContactPersonField\", realContactPerson ) );\n        }\n      }\n    }\n    // Contact Phone\n    if ( !Utils.isEmpty( meta.getContactPhone() ) ) {\n      // cache the position of the destination field\n      if ( data.indexOfContactPhone < 0 ) {\n        String realContactPhone = meta.getContactPhone();\n        data.indexOfContactPhone = data.previousRowMeta.indexOfValue( realContactPhone );\n        if ( data.indexOfContactPhone < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindContactPhoneField\", realContactPhone ) );\n        }\n      }\n    }\n    // cache the position of the Server field\n    if ( data.indexOfServer < 0 ) {\n      String realServer = meta.getServer();\n      data.indexOfServer = data.previousRowMeta.indexOfValue( realServer );\n      if ( data.indexOfServer < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindServerField\", realServer ) );\n      }\n    }\n    // Port\n    if ( !Utils.isEmpty( meta.getPort() ) ) {\n      // cache the position of the port field\n      if ( data.indexOfPort < 0 ) {\n        String realPort = meta.getPort();","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L316-L352","documentation":"Thrown by cacheFieldsPosition when the contact-phone field configured in Mail meta cannot be found in the incoming row's RowMeta. Checked only when a contact-phone field is configured; indexOfValue returning -1 throws the KettleException.","triggerScenarios":"meta.getContactPhone() is non-empty and data.indexOfContactPhone == -1 after indexOfValue on previousRowMeta.","commonSituations":"Phone column renamed or dropped upstream; mis-typed field name in the Mail step; conditional upstream logic that sometimes omits the column.","solutions":["Correct the 'Contact Phone fieldname' setting to match an existing column","Guarantee the column upstream (default empty string if needed)","Clear the contact-phone field setting if not used"],"exampleFix":"// before\nmeta.setContactPhone(\"phone_no\");\n// after\nmeta.setContactPhone(\"phone_number\");","handlingStrategy":"validation","validationCode":"// ensure the contact-phone field exists when configured\nif (!isEmpty(meta.getContactPhone()) && rowMeta.indexOfValue(meta.getContactPhone()) < 0) {\n  logError(\"Contact phone field not in stream: \" + meta.getContactPhone());\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindContactPhoneField\")) {\n    logError(\"Contact phone field missing: \" + e.getMessage());\n  }\n}","preventionTips":["Configure contact-phone only when the column exists on all paths","Default empty-string via Add constants for optional data","Preview rows to confirm the field list before running"],"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"}