{"record":{"id":"146691da0ed61f6f","repo":"pentaho/pentaho-kettle","slug":"unknown-field-specified-to-replace-with-a-formula-result","errorCode":null,"errorMessage":"Unknown field specified to replace with a formula result: [","messagePattern":"Unknown field specified to replace with a formula result: \\[","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java","lineNumber":83,"sourceCode":"      first = false;\n\n      data.outputRowMeta = getInputRowMeta().clone();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n\n      // Create the context\n      data.context = new RowForumulaContext( data.outputRowMeta );\n      data.parser = new FormulaParser();\n\n      // Calculate replace indexes...\n      //\n      data.replaceIndex = new int[meta.getFormula().length];\n      for ( int i = 0; i < meta.getFormula().length; i++ ) {\n        FormulaMetaFunction fn = meta.getFormula()[i];\n        if ( !Utils.isEmpty( fn.getReplaceField() ) ) {\n          data.replaceIndex[i] = getInputRowMeta().indexOfValue( fn.getReplaceField() );\n          if ( data.replaceIndex[i] < 0 ) {\n            throw new KettleException( \"Unknown field specified to replace with a formula result: [\"\n              + fn.getReplaceField() + \"]\" );\n          }\n        } else {\n          data.replaceIndex[i] = -1;\n        }\n      }\n    }\n\n    if ( log.isRowLevel() ) {\n      logRowlevel( \"Read row #\" + getLinesRead() + \" : \" + Arrays.toString( r ) );\n    }\n\n    Object[] outputRowData = calcFields( getInputRowMeta(), r );\n    putRow( data.outputRowMeta, outputRowData ); // copy row to possible alternate rowset(s).\n\n    if ( log.isRowLevel() ) {\n      logRowlevel( \"Wrote row #\" + getLinesWritten() + \" : \" + Arrays.toString( r ) );\n    }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/formula/Formula.java#L65-L101","documentation":"KettleException thrown in Formula.processRow() when a formula entry specifies a 'replace field' that does not exist in the incoming row's field metadata. The step resolves the replace field's index via getInputRowMeta().indexOfValue(); a negative index means the field name is misspelled or absent at runtime.","triggerScenarios":"A Formula step defines formula[i].replaceField, but that field is missing from the input row metadata when the first row arrives — e.g. renamed upstream, not yet produced by a later step, or removed after editing the transform.","commonSituations":"Reordering steps so the Formula step runs before the field it replaces is created; renaming a CSV column; case-sensitive field name mismatch; replacing a field whose source stream is optional.","solutions":["Correct the 'Replace value' field name in the Formula step to exactly match an input field (case-sensitive).","Reconnect/re-synchronize the step's hop so the field list refreshes in the dialog.","Ensure the upstream step that creates the field executes before the Formula step.","Use the step's 'Get fields' button to pick an existing field instead of typing it."],"exampleFix":"// before (formula meta)\nfn.setReplaceField(\"amount_old\"); // field no longer exists\n// after\nfn.setReplaceField(\"amount\"); // matches actual input field","handlingStrategy":"validation","validationCode":"// before running the transformation\nfor (FormulaMetaFunction fn : meta.getFormula()) {\n  if (!Utils.isEmpty(fn.getReplaceField()) && inputRowMeta.indexOfValue(fn.getReplaceField()) < 0)\n    throw new KettleException(\"Replace field missing: \" + fn.getReplaceField());\n}","typeGuard":null,"tryCatchPattern":"try { return formulaStepData(row); } catch (KettleException e) { log.error(\"Check replace field names in Formula step: \" + e.getMessage()); throw e; }","preventionTips":["Pick fields with the dialog picker instead of typing","Re-verify step config after renaming upstream fields","Validate the transformation before running","Keep field names lowercase to dodge case issues"],"tags":["formula","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"}