{"record":{"id":"d25263636d10d1b4","repo":"pentaho/pentaho-kettle","slug":"writetolog-log-cannotfindfield","errorCode":null,"errorMessage":"WriteToLog.Log.CanNotFindField","messagePattern":"WriteToLog\\.Log\\.CanNotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/writetolog/WriteToLog.java","lineNumber":78,"sourceCode":"    }\n\n    // Limit hit? skip\n    if ( rowCounterLimitHit ) {\n      putRow( getInputRowMeta(), r ); // copy row to output\n      return true;\n    }\n\n    if ( first ) {\n      first = false;\n\n      if ( meta.getFieldName() != null && meta.getFieldName().length > 0 ) {\n        data.fieldnrs = new int[meta.getFieldName().length];\n\n        for ( int i = 0; i < data.fieldnrs.length; i++ ) {\n          data.fieldnrs[i] = getInputRowMeta().indexOfValue( meta.getFieldName()[i] );\n          if ( data.fieldnrs[i] < 0 ) {\n            logError( BaseMessages.getString( PKG, \"WriteToLog.Log.CanNotFindField\", meta.getFieldName()[i] ) );\n            throw new KettleException( BaseMessages.getString( PKG, \"WriteToLog.Log.CanNotFindField\", meta\n              .getFieldName()[i] ) );\n          }\n        }\n      } else {\n        data.fieldnrs = new int[getInputRowMeta().size()];\n        for ( int i = 0; i < data.fieldnrs.length; i++ ) {\n          data.fieldnrs[i] = i;\n        }\n      }\n      data.fieldnr = data.fieldnrs.length;\n      data.loglevel = meta.getLogLevelByDesc();\n      data.logmessage = Const.NVL( this.environmentSubstitute( meta.getLogMessage() ), \"\" );\n      if ( !Utils.isEmpty( data.logmessage ) ) {\n        data.logmessage += Const.CR + Const.CR;\n      }\n    } // end if first\n\n    // We don't need to calculate if step log level is lower than the run log level","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/writetolog/WriteToLog.java#L60-L96","documentation":"WriteToLog.processRow() resolves each configured log field name against the incoming row layout via getInputRowMeta().indexOfValue(). If a configured field name is not present in the input stream, indexOfValue() returns -1, and the step logs and throws this KettleException so the transformation fails fast. It exists to catch metadata drift between what the step expects and what the previous step actually delivers.","triggerScenarios":"Running a transformation where meta.getFieldName()[i] (a field configured in the Write To Log step dialog) does not exist in the input row metadata, i.e. data.fieldnrs[i] < 0. Occurs in processRow() during first-row initialization after all fields are resolved.","commonSituations":"Renaming or deleting an upstream field without updating the Write To Log step; connecting a different hop into the step; editing the transformation XML/repo by hand; case-sensitive field name mismatch after a database source column change.","solutions":["Open the Write To Log step dialog and remove or correct the field name(s) that no longer exist in the incoming stream.","Run a 'Fields' / input preview on the previous step to see the actual field names and match them exactly (Kettle field names are case-sensitive).","If fields are dynamic, clear the Fields table or use 'Get Fields' in the dialog to repopulate from the current input metadata.","Check the transformation after a source schema change (e.g. a table column renamed) and fix dependent steps."],"exampleFix":"// before (configured field no longer in stream)\nString[] fieldName = { \"customer_name\", \"amount\" };\n// after (aligned with actual input row)\nString[] fieldName = { \"CUSTOMER_NM\", \"amount\" }; // names matching upstream row metadata","handlingStrategy":"validation","validationCode":"for (String name : writeToLogMeta.getFieldName()) {\n  if (inputRowMeta.indexOfValue(name) < 0) {\n    throw new KettleException(\"Field not in input stream: \" + name);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  transformation.execute();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"WriteToLog.Log.CanNotFindField\")) {\n    // correct the step's field list against actual input metadata, then retry\n  }\n}","preventionTips":["Use 'Get Fields' in the step dialog instead of typing field names manually.","Re-validate steps after renaming upstream columns.","Keep field lists minimal; log whole rows when field names are unstable.","Add a step-level unit test that checks field resolution against sample metadata."],"tags":["kettle","pentaho","step-execution","field-resolution"],"backgroundTag":"entity-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"}