{"record":{"id":"e0b7f31eed034be9","repo":"pentaho/pentaho-kettle","slug":"jsonoutput-exception-fieldnotfound","errorCode":"JsonOutput.Exception.FieldNotFound","errorMessage":"JsonOutput.Exception.FieldNotFound","messagePattern":"JsonOutput\\.Exception\\.FieldNotFound","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsonoutput/JsonOutput.java","lineNumber":205,"sourceCode":"    if ( first ) {\n      first = false;\n      startProcessingDate = new Date();\n      data.inputRowMeta = getInputRowMeta();\n      data.inputRowMetaSize = data.inputRowMeta.size();\n      if ( data.outputValue ) {\n        data.outputRowMeta = data.inputRowMeta.clone();\n        meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n                        metaStore );\n      }\n\n      // Cache the field name indexes\n      //\n      data.nrFields = meta.getOutputFields().length;\n      data.fieldIndexes = new int[data.nrFields];\n      for ( int i = 0; i < data.nrFields; i++ ) {\n        data.fieldIndexes[i] = data.inputRowMeta.indexOfValue( meta.getOutputFields()[i].getFieldName() );\n        if ( data.fieldIndexes[i] < 0 ) {\n          throw new KettleException( BaseMessages.getString( PKG, \"JsonOutput.Exception.FieldNotFound\" ) );\n        }\n        JsonOutputField field = meta.getOutputFields()[i];\n        field.setElementName( environmentSubstitute( field.getElementName() ) );\n      }\n    }\n\n    data.rowsAreSafe = false;\n    compatibilityFactory.execute( r );\n\n    if ( data.writeToFile && !data.outputValue ) {\n      putRow( data.inputRowMeta, r ); // in case we want it go further...\n      incrementLinesOutput();\n    }\n    return true;\n  }\n\n  @SuppressWarnings( \"unchecked\" )\n  private void outPutRow( Object[] rowData ) throws KettleStepException {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsonoutput/JsonOutput.java#L187-L223","documentation":"JsonOutput.processRow resolves each configured output field's index in the incoming row metadata via indexOfValue. If a configured field name does not exist in the input row, it throws JsonOutput.Exception.FieldNotFound. This guards against silently writing incomplete JSON when the step's field mapping is stale.","triggerScenarios":"The 'Fields' grid of the JSON Output step lists a field name that is not present in the row schema arriving at the step (indexOfValue returns -1). Happens during processRow's initial metadata pass.","commonSituations":"Renaming or deleting an upstream field without updating the JSON Output grid; a stream that conditionally includes fields; copying a transformation between environments where a preceding step's output differs; typos in field names.","solutions":["Open the JSON Output step, remove or rename the stale entry in the Fields grid so it matches an actual incoming field.","Click 'Get Fields' in the step dialog to re-populate the field list from the incoming row metadata.","Run with Preview on the previous step to confirm the actual field names arriving at JSON Output.","Ensure the producing step always emits the field (add a default value with e.g. 'Value Mapper' or 'If field value is null')."],"exampleFix":"// before (JSON Output step XML referencing a removed field)\n<field><name>oldField</name><element>oldField</element></field>\n// after\n<field><name>renamedField</name><element>renamedField</element></field>","handlingStrategy":"validation","validationCode":"// In a Modified Java Script / User Defined Java step before JSON Output:\n// verify all configured fields exist on the row\nString[] required = {\"id\", \"name\", \"amount\"};\nfor (String f : required) {\n  if (get(Fields.In, f) == null) throw new RuntimeException(\"Missing field for JSON Output: \" + f);\n}","typeGuard":null,"tryCatchPattern":"try { transform.run(); } catch (KettleException e) {\n  if (e.getMessage().contains(\"JsonOutput.Exception.FieldNotFound\")) {\n    log.error(\"JSON Output field grid out of sync with incoming row schema; run Get Fields.\");\n  }\n  throw e;\n}","preventionTips":["Use 'Get Fields' in the JSON Output dialog after any upstream schema change.","Avoid renaming/deleting upstream fields without updating downstream step grids.","Keep transformations small so schema drift is easy to spot with Preview."],"tags":["pdi","kettle","field-mapping","schema-mismatch","json-output"],"backgroundTag":"record-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"}