pentaho/pentaho-kettle · error · KettleException

JsonOutput.Exception.FieldNotFound

JsonOutput.Exception.FieldNotFound

Error message

JsonOutput.Exception.FieldNotFound

What it means

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.

Solutions

  1. Open the JSON Output step, remove or rename the stale entry in the Fields grid so it matches an actual incoming field.
  2. Click 'Get Fields' in the step dialog to re-populate the field list from the incoming row metadata.
  3. Run with Preview on the previous step to confirm the actual field names arriving at JSON Output.
  4. Ensure the producing step always emits the field (add a default value with e.g. 'Value Mapper' or 'If field value is null').

Example fix

// before (JSON Output step XML referencing a removed field)
<field><name>oldField</name><element>oldField</element></field>
// after
<field><name>renamedField</name><element>renamedField</element></field>
Defensive patterns

Strategy: validation

Validate before calling

// In a Modified Java Script / User Defined Java step before JSON Output:
// verify all configured fields exist on the row
String[] required = {"id", "name", "amount"};
for (String f : required) {
  if (get(Fields.In, f) == null) throw new RuntimeException("Missing field for JSON Output: " + f);
}

Try / catch

try { transform.run(); } catch (KettleException e) {
  if (e.getMessage().contains("JsonOutput.Exception.FieldNotFound")) {
    log.error("JSON Output field grid out of sync with incoming row schema; run Get Fields.");
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/e0b7f31eed034be9. Report an issue: GitHub.

Appendix: source

Thrown at plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsonoutput/JsonOutput.java:205

    if ( first ) {
      first = false;
      startProcessingDate = new Date();
      data.inputRowMeta = getInputRowMeta();
      data.inputRowMetaSize = data.inputRowMeta.size();
      if ( data.outputValue ) {
        data.outputRowMeta = data.inputRowMeta.clone();
        meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,
                        metaStore );
      }

      // Cache the field name indexes
      //
      data.nrFields = meta.getOutputFields().length;
      data.fieldIndexes = new int[data.nrFields];
      for ( int i = 0; i < data.nrFields; i++ ) {
        data.fieldIndexes[i] = data.inputRowMeta.indexOfValue( meta.getOutputFields()[i].getFieldName() );
        if ( data.fieldIndexes[i] < 0 ) {
          throw new KettleException( BaseMessages.getString( PKG, "JsonOutput.Exception.FieldNotFound" ) );
        }
        JsonOutputField field = meta.getOutputFields()[i];
        field.setElementName( environmentSubstitute( field.getElementName() ) );
      }
    }

    data.rowsAreSafe = false;
    compatibilityFactory.execute( r );

    if ( data.writeToFile && !data.outputValue ) {
      putRow( data.inputRowMeta, r ); // in case we want it go further...
      incrementLinesOutput();
    }
    return true;
  }

  @SuppressWarnings( "unchecked" )
  private void outPutRow( Object[] rowData ) throws KettleStepException {

View on GitHub (pinned to f3058517a1)