{"record":{"id":"31fcbec62d019478","repo":"pentaho/pentaho-kettle","slug":"replacestring-exception-fieldtypenotstring","errorCode":null,"errorMessage":"ReplaceString.Exception.FieldTypeNotString","messagePattern":"ReplaceString\\.Exception\\.FieldTypeNotString","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/replacestring/ReplaceString.java","lineNumber":181,"sourceCode":"\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(\n              PKG, \"ReplaceString.Exception.FieldRequired\", field ) );\n          }\n        } else {\n          data.replaceFieldIndex[i] = -1;\n          data.replaceByString[i] = environmentSubstitute( meta.getReplaceByString()[i] );\n        }","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/replacestring/ReplaceString.java#L163-L199","documentation":"ReplaceString only supports replacing within String fields. For each configured field it checks the incoming value metadata type; if the type is not ValueMetaInterface.TYPE_STRING it throws KettleStepException 'ReplaceString.Exception.FieldTypeNotString' with the field name.","triggerScenarios":"The configured 'In stream field' resolves to a field whose type is Integer, Number, Date, Boolean, etc., rather than String.","commonSituations":"Hooking ReplaceString directly to a CSV column parsed as a number; a Calculator/Formula step produced a numeric field; forgetting a 'Field to string'/Text file output string conversion upstream.","solutions":["Convert the field to String upstream (e.g. 'Value Mapper', 'Formula', or Select values 'Metadata' tab change type to String).","Select a different, String-typed field in the step settings.","Change upstream input parsing (e.g. Text file input format) so the column arrives as String."],"exampleFix":"// before: numeric field passed straight to ReplaceString\n// row: amount (Integer)\n// after: convert upstream in Select values (Metadata tab)\n// amount: Integer -> String\nmeta.setFieldInStream( new String[] { \"amount_as_string\" } );","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["type-mismatch","row-metadata","string"],"backgroundTag":"type-mismatch","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"}