{"record":{"id":"efcf9e4af79ad08a","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfindportfield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindPortField","messagePattern":"Mail\\.Exception\\.CouldnotFindPortField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":355,"sourceCode":"      }\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();\n        data.indexOfPort = data.previousRowMeta.indexOfValue( realPort );\n        if ( data.indexOfPort < 0 ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"Mail.Exception.CouldnotFindPortField\", realPort ) );\n        }\n      }\n    }\n    // Authentication\n    if ( meta.isUsingAuthentication().equals( MailMeta.AUTENTICATION_BASIC ) ) {\n      // cache the position of the Authentication password field\n      if ( data.indexOfAuthenticationPass < 0 ) {\n        String realAuthenticationPassword = Utils.resolvePassword( variables, meta.getAuthenticationPassword() );\n        data.indexOfAuthenticationPass = data.previousRowMeta.indexOfValue( realAuthenticationPassword );\n        if ( data.indexOfAuthenticationPass < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindAuthenticationPassField\", realAuthenticationPassword ) );\n        }\n      }\n    }\n    // cache the position of the Authentication user field\n    if ( meta.isUsingAuthentication().equals( MailMeta.AUTENTICATION_BASIC ) || meta.isUsingAuthentication().equals( MailMeta.AUTENTICATION_OAUTH ) ) {\n      if ( data.indexOfAuthenticationUser < 0 ) {","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L337-L373","documentation":"The Mail transformation step could not locate the port field in the incoming row's field metadata. The step is configured to read the SMTP port dynamically from a field, but data.previousRowMeta.indexOfValue(realPort) returned -1, meaning no field with that name exists in the input stream. Kettle throws this KettleException during cacheFieldsPosition before any mail is sent.","triggerScenarios":"meta.getPort() is non-empty (a port field name is configured) and the field name does not exactly match any field in the incoming row, so data.indexOfPort stays -1.","commonSituations":"Typo in the port field name in the Mail step dialog; an upstream step was renamed or removed so the field disappeared from the stream; case-sensitivity mismatch between configured name and actual field name.","solutions":["Open the Mail step settings and verify the 'Port' field name exactly matches a field in the input stream (names are case-sensitive).","Check the upstream steps' field previews (right-click > Preview) to confirm the port field actually reaches this step.","If the port is a fixed value instead, clear the Port field so the dynamic lookup is skipped."],"exampleFix":"// before\nString realPort = meta.getPort(); // \"smtp_port\" but row has \"SMTP_PORT\"\n// after\n// rename the field upstream or set the step's port field to \"SMTP_PORT\"\n// or leave port field empty and hardcode the SMTP port in the settings","handlingStrategy":"validation","validationCode":"// Before executing the transformation, verify the field exists:\nif (meta.getPort() != null && !meta.getPort().isEmpty()) {\n  if (rowMeta.indexOfValue(meta.getPort()) < 0) {\n    throw new KettleException(\"Port field not found in input stream: \" + meta.getPort());\n  }\n}","typeGuard":null,"tryCatchPattern":"try { transformation.startThreads(); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindPortField\")) { logError(\"Check the Mail step port field configuration\"); } throw e; }","preventionTips":["Always preview the input rows of the Mail step after changing upstream steps.","Use the field-name dropdowns in the step dialog instead of typing names manually.","Re-check field names after any upstream rename or refactor."],"tags":["kettle","pentaho","mail-step","field-lookup"],"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"}