{"record":{"id":"34bfe760f9ae7506","repo":"pentaho/pentaho-kettle","slug":"replacestring-exception-fieldrequired","errorCode":null,"errorMessage":"ReplaceString.Exception.FieldRequired","messagePattern":"ReplaceString\\.Exception\\.FieldRequired","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/replacestring/ReplaceString.java","lineNumber":175,"sourceCode":"\n      // What's the format of the output row?\n      data.outputRowMeta = getInputRowMeta().clone();\n      data.inputFieldsNr = data.outputRowMeta.size();\n      meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n        metaStore );\n\n      data.numFields = meta.getFieldInStream().length;\n      data.inStreamNrs = new int[data.numFields];\n      data.outStreamNrs = new String[data.numFields];\n      data.patterns = new Pattern[data.numFields];\n      data.replaceByString = new String[data.numFields];\n      data.setEmptyString = new boolean[data.numFields];\n      data.replaceFieldIndex = new int[data.numFields];\n\n      for ( int i = 0; i < data.numFields; i++ ) {\n        data.inStreamNrs[i] = getInputRowMeta().indexOfValue( meta.getFieldInStream()[i] );\n        if ( data.inStreamNrs[i] < 0 ) {\n          throw new KettleStepException( BaseMessages.getString(\n            PKG, \"ReplaceString.Exception.FieldRequired\", meta.getFieldInStream()[i] ) );\n        }\n\n        // check field type\n        if ( getInputRowMeta().getValueMeta( data.inStreamNrs[i] ).getType() != ValueMetaInterface.TYPE_STRING ) {\n          throw new KettleStepException( BaseMessages.getString(\n            PKG, \"ReplaceString.Exception.FieldTypeNotString\", meta.getFieldInStream()[i] ) );\n        }\n\n        data.outStreamNrs[i] = environmentSubstitute( meta.getFieldOutStream()[i] );\n        data.patterns[ i ] = buildPattern( !meta.getUseRegEx()[ i ], meta.getCaseSensitive()[ i ],\n          meta.getWholeWord()[ i ], environmentSubstitute( meta.getReplaceString()[ i ] ), meta.isUnicode()[ i ] );\n\n        String field = meta.getFieldReplaceByString()[i];\n        if ( !Utils.isEmpty( field ) ) {\n          data.replaceFieldIndex[i] = getInputRowMeta().indexOfValue( field );\n          if ( data.replaceFieldIndex[i] < 0 ) {\n            throw new KettleStepException( BaseMessages.getString(","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/replacestring/ReplaceString.java#L157-L193","documentation":"During processRow initialization, ReplaceString looks up each configured in-stream field via getInputRowMeta().indexOfValue(meta.getFieldInStream()[i]); a negative index means the field named in the step configuration does not exist in the incoming row, so it throws KettleStepException 'ReplaceString.Exception.FieldRequired' with the field name.","triggerScenarios":"The 'In stream field' configured in the ReplaceString step (e.g. fieldname not present, misspelled, or produced by an upstream step that was removed/renamed) is absent from the row metadata.","commonSituations":"Renaming an upstream field without updating the step; changing field casing; removing a Select values / Text file input column; test harnesses (testProcessRow_* tests) that set up rows lacking the configured field.","solutions":["Compare the configured 'In stream field' name against the actual upstream row fields (preview the input).","Fix the spelling/case of the field name in the step settings.","Restore the missing field in the upstream step that should produce it.","Reorder so ReplaceString runs after the step emitting the field."],"exampleFix":"// before: field not in stream\nmeta.setFieldInStream( new String[] { \"message\" } ); // upstream has \"msg\"\n// after\nmeta.setFieldInStream( new String[] { \"msg\" } ); // matches actual upstream field","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["field-lookup","row-metadata","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"}