{"record":{"id":"07978762e990a34d","repo":"pentaho/pentaho-kettle","slug":"unknown-field-specified-to-replace-with-a-formula-result-079787","errorCode":null,"errorMessage":"Unknown field specified to replace with a formula result: [{replaceField}]","messagePattern":"Unknown field specified to replace with a formula result: \\[(.+?)\\]","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/janino/JaninoMeta.java","lineNumber":166,"sourceCode":"      if ( Utils.isEmpty( fn.getReplaceField() ) ) {\n        // Not replacing a field.\n        if ( !Utils.isEmpty( fn.getFieldName() ) ) {\n          // It's a new field!\n\n          try {\n            ValueMetaInterface v = ValueMetaFactory.createValueMeta( fn.getFieldName(), fn.getValueType() );\n            v.setLength( fn.getValueLength(), fn.getValuePrecision() );\n            v.setOrigin( name );\n            row.addValueMeta( v );\n          } catch ( Exception e ) {\n            throw new KettleStepException( e );\n          }\n        }\n      } else {\n        // Replacing a field\n        int index = row.indexOfValue( fn.getReplaceField() );\n        if ( index < 0 ) {\n          throw new KettleStepException( \"Unknown field specified to replace with a formula result: [\"\n            + fn.getReplaceField() + \"]\" );\n        }\n        // Change the data type etc.\n        //\n        ValueMetaInterface v = row.getValueMeta( index ).clone();\n        v.setLength( fn.getValueLength(), fn.getValuePrecision() );\n        v.setOrigin( name );\n        row.setValueMeta( index, v ); // replace it\n      }\n    }\n  }\n\n  /**\n   * Checks the settings of this step and puts the findings in a remarks List.\n   *\n   * @param remarks\n   *          The list to put the remarks in @see org.pentaho.di.core.CheckResult\n   * @param stepMeta","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/janino/JaninoMeta.java#L148-L184","documentation":"Thrown by JaninoMeta.getFields() (metadata-time row-shape calculation) when a formula is set to replace a field that is not present in the incoming row. This fails transformation validation before execution, mirroring the runtime check in Janino.processRow.","triggerScenarios":"getFields() called by Kettle during transformation layout checking; a JaninoMetaFunction has a non-empty replaceField and row.indexOfValue(replaceField) == -1.","commonSituations":"Same as the runtime variant: upstream field renamed/deleted, hop rewired to a different stream, transformation opened after another developer changed the upstream Select Values step.","solutions":["Correct the 'Replace value' field name in the Formula step dialog.","Clear 'Replace value' to append a new field instead.","Reconnect the hop to the correct upstream step that emits the field.","Run a transformation check (Ctrl+T verify) to catch all such metadata errors before execution."],"exampleFix":"// before\nfn.setReplaceField(\"amount_old\");\n// after\nfn.setReplaceField(\"amount\");","handlingStrategy":"validation","validationCode":"// Metadata-time check mirroring getFields()\nif (fn.getReplaceField() != null && !fn.getReplaceField().isEmpty()\n    && row.indexOfValue(fn.getReplaceField()) < 0) {\n  throw new IllegalStateException(\"Replace field missing from upstream row: \" + fn.getReplaceField());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the transformation check (verify) before scheduling.","Keep upstream field contracts stable; document stream schemas.","Clear 'Replace value' when adding new fields instead of replacing."],"tags":["kettle","formula","validation"],"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"}