{"record":{"id":"920d13349af402d8","repo":"pentaho/pentaho-kettle","slug":"creditcardvalidator-exception-couldnotfindfield","errorCode":"CreditCardValidator.Exception.CouldnotFindField","errorMessage":"CreditCardValidator.Exception.CouldnotFindField","messagePattern":"CreditCardValidator\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/credit-card-validator/impl/src/main/java/org/pentaho/di/trans/steps/creditcardvalidator/CreditCardValidator.java","lineNumber":88,"sourceCode":"      // get the RowMeta\n      data.previousRowMeta = getInputRowMeta().clone();\n      data.NrPrevFields = data.previousRowMeta.size();\n      data.outputRowMeta = data.previousRowMeta;\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n\n      // Check if field is provided\n      if ( Utils.isEmpty( meta.getDynamicField() ) ) {\n        logError( BaseMessages.getString( PKG, \"CreditCardValidator.Error.CardFieldMissing\" ) );\n        throw new KettleException( BaseMessages.getString( PKG, \"CreditCardValidator.Error.CardFieldMissing\" ) );\n      }\n\n      // cache the position of the field\n      if ( data.indexOfField < 0 ) {\n        data.indexOfField = getInputRowMeta().indexOfValue( meta.getDynamicField() );\n        if ( data.indexOfField < 0 ) {\n          // The field is unreachable !\n          throw new KettleException( BaseMessages.getString(\n            PKG, \"CreditCardValidator.Exception.CouldnotFindField\", meta.getDynamicField() ) );\n        }\n      }\n      data.realResultFieldname = environmentSubstitute( meta.getResultFieldName() );\n      if ( Utils.isEmpty( data.realResultFieldname ) ) {\n        throw new KettleException( BaseMessages\n          .getString( PKG, \"CreditCardValidator.Exception.ResultFieldMissing\" ) );\n      }\n      data.realCardTypeFieldname = environmentSubstitute( meta.getCardType() );\n      data.realNotValidMsgFieldname = environmentSubstitute( meta.getNotValidMsg() );\n\n    } // End If first\n\n    Object[] outputRow = RowDataUtil.allocateRowData( data.outputRowMeta.size() );\n    for ( int i = 0; i < data.NrPrevFields; i++ ) {\n      outputRow[i] = r[i];\n    }\n    try {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/credit-card-validator/impl/src/main/java/org/pentaho/di/trans/steps/creditcardvalidator/CreditCardValidator.java#L70-L106","documentation":"After locating the configured input field name, the step looks it up in the incoming row's metadata via indexOfValue. If the field name is configured but does not exist in the input stream, the step throws KettleException with CouldnotFindField naming the missing field.","triggerScenarios":"processRow reaches indexOfValue(meta.getDynamicField()) and returns -1 because no input field matches the configured name.","commonSituations":"Upstream step renamed or dropped the field; case-sensitivity mismatch between configured name and actual field; running the transformation after changing a Select values step; field only produced conditionally upstream.","solutions":["Fix the configured field name to match an actual input field (mind case)","Add/repair the upstream step that should produce the field","Use a 'Select values' step to rename the field before this step"],"exampleFix":"// before\nmeta.setDynamicField(\"CardNumber\"); // not in stream\n// after\nmeta.setDynamicField(\"cardNumber\"); // matches upstream field name","handlingStrategy":"validation","validationCode":"String configured = meta.getDynamicField();\nif (!inputRowMeta.getFieldNames().stream().anyMatch(configured::equals)) throw new IllegalArgumentException(\"Field not in stream: \" + configured);","typeGuard":null,"tryCatchPattern":"try { trans.execute(...); } catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindField\")) { logError(\"Fix the configured field name\"); } }","preventionTips":["Check field names in a preview before running","Keep field naming consistent (same case) across steps","Use a Select values step to guarantee the field exists"],"tags":["kettle","pdi","field-mapping"],"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"}