{"record":{"id":"bf3814d25c297d6a","repo":"pentaho/pentaho-kettle","slug":"mail-exception-couldnotfindcommentfield","errorCode":null,"errorMessage":"Mail.Exception.CouldnotFindCommentField","messagePattern":"Mail\\.Exception\\.CouldnotFindCommentField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java","lineNumber":401,"sourceCode":"    if ( !Utils.isEmpty( meta.getSubject() ) ) {\n      // cache the position of the subject field\n      if ( data.indexOfSubject < 0 ) {\n        String realSubject = meta.getSubject();\n        data.indexOfSubject = data.previousRowMeta.indexOfValue( realSubject );\n        if ( data.indexOfSubject < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindSubjectField\", realSubject ) );\n        }\n      }\n    }\n    // Mail Comment\n    if ( !Utils.isEmpty( meta.getComment() ) ) {\n      // cache the position of the comment field\n      if ( data.indexOfComment < 0 ) {\n        String realComment = meta.getComment();\n        data.indexOfComment = data.previousRowMeta.indexOfValue( realComment );\n        if ( data.indexOfComment < 0 ) {\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"Mail.Exception.CouldnotFindCommentField\", realComment ) );\n        }\n      }\n    }\n\n    if ( meta.isAttachContentFromField() ) {\n      // We are dealing with file content directly loaded from file\n      // and not physical file\n      String attachedContentField = meta.getAttachContentField();\n      if ( Utils.isEmpty( attachedContentField ) ) {\n        // Empty Field\n        throw new KettleException( BaseMessages.getString( PKG, \"Mail.Exception.AttachedContentFieldEmpty\" ) );\n      }\n      data.indexOfAttachedContent = data.previousRowMeta.indexOfValue( attachedContentField );\n      if ( data.indexOfAttachedContent < 0 ) {\n        throw new KettleException( BaseMessages.getString(\n          PKG, \"Mail.Exception.CouldnotFindAttachedContentField\", attachedContentField ) );\n      }","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mail/impl/src/main/java/org/pentaho/di/trans/steps/mail/Mail.java#L383-L419","documentation":"The Mail step is configured to take the mail comment from a field, but the configured comment field name was not found in the incoming row. The indexOfValue lookup in cacheFieldsPosition returned -1, so this KettleException is thrown before processing.","triggerScenarios":"meta.getComment() is non-empty and data.previousRowMeta.indexOfValue(realComment) < 0, i.e. no field in the input row matches the configured comment field name.","commonSituations":"Literal comment text entered into a field-name setting; upstream field renamed/removed; copy-pasted step from a transformation with a different row layout.","solutions":["Confirm the 'Comment' setting contains the exact name of a field present in the input stream.","Preview upstream rows and fix any rename/mismatch.","If a constant comment is needed, remove the field reference and set the comment statically."],"exampleFix":"// before\n// Comment field: \"See attached invoice\" (literal text)\n// after\n// Upstream step creates field \"mail_comment\" = 'See attached invoice';\n// Comment field set to \"mail_comment\"","handlingStrategy":"validation","validationCode":"if (meta.getComment() != null && !meta.getComment().isEmpty()\n    && rowMeta.indexOfValue(meta.getComment()) < 0) {\n  throw new KettleException(\"Comment field not found in input stream: \" + meta.getComment());\n}","typeGuard":null,"tryCatchPattern":"try { sendMail(); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindCommentField\")) { logError(\"Comment setting must reference an existing stream field\"); } throw e; }","preventionTips":["The Comment setting is a field name reference, not free text; supply literals via upstream steps.","Verify field existence after any upstream schema change.","Use dropdown field pickers in the step dialog to avoid typos."],"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"}