{"record":{"id":"f56cb97a42b67112","repo":"pentaho/pentaho-kettle","slug":"elasticsearchbulk-error-nojsonfieldformat","errorCode":"ElasticSearchBulk.Error.NoJsonFieldFormat","errorMessage":"ElasticSearchBulk.Error.NoJsonFieldFormat","messagePattern":"ElasticSearchBulk\\.Error\\.NoJsonFieldFormat","errorType":"validation","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"plugins/elasticsearch-bulk-insert/core/src/main/java/org/pentaho/di/trans/steps/elasticsearchbulk/ElasticSearchBulk.java","lineNumber":244,"sourceCode":"      throw new KettleStepException( BaseMessages.getString( PKG, \"ElasticSearchBulkDialog.Error.NoNodesFound\" ) );\n    } catch ( Exception e ) {\n      throw new KettleStepException( BaseMessages.getString( PKG, \"ElasticSearchBulk.Log.Exception\", e\n              .getLocalizedMessage() ), e );\n    }\n  }\n\n  /**\n   * @param row\n   * @param requestBuilder\n   */\n  private void addSourceFromJsonString( Object[] row, IndexRequestBuilder requestBuilder ) throws KettleStepException {\n    Object jsonString = row[jsonFieldIdx];\n    if ( jsonString instanceof byte[] ) {\n      requestBuilder.setSource( (byte[]) jsonString, XContentType.JSON );\n    } else if ( jsonString instanceof String ) {\n      requestBuilder.setSource( (String) jsonString, XContentType.JSON );\n    } else {\n      throw new KettleStepException( BaseMessages.getString( \"ElasticSearchBulk.Error.NoJsonFieldFormat\" ) );\n    }\n  }\n\n  /**\n   * @param requestBuilder\n   * @param rowMeta\n   * @param row\n   * @throws IOException\n   */\n  private void addSourceFromRowFields( IndexRequestBuilder requestBuilder, RowMetaInterface rowMeta, Object[] row )\n          throws IOException {\n    XContentBuilder jsonBuilder = XContentFactory.jsonBuilder().startObject();\n\n    for ( int i = 0; i < rowMeta.size(); i++ ) {\n      if ( idFieldIndex != null && i == idFieldIndex ) { // skip id\n        continue;\n      }\n","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/elasticsearch-bulk-insert/core/src/main/java/org/pentaho/di/trans/steps/elasticsearchbulk/ElasticSearchBulk.java#L226-L262","documentation":"In ElasticSearchBulk.addSourceFromJsonString(), when the step is configured to take the document source from a JSON field, the field value must be a String or byte[]. Any other Java type (e.g. Integer, BigDecimal, Date) cannot be used as the raw JSON source, so a KettleStepException with key 'ElasticSearchBulk.Error.NoJsonFieldFormat' is thrown.","triggerScenarios":"indexRow() -> addSourceFromJsonString() with 'json field' source format selected, and row[jsonFieldIdx] is neither byte[] nor String — typically a numeric, boolean, or Date-typed field from the stream.","commonSituations":"Upstream step emits a Number/Date field but the user selected 'From JSON field' instead of building the document from fields; JSON read into a typed field by a JSON input step without forcing string type.","solutions":["Convert the field to String in a preceding step (Select values -> metadata type String, or use 'Get fields' / User Defined Java Expression)","Or switch the step's source format from 'From JSON field' to building the document from stream fields","Check the field mapping in the step dialog points at the actual JSON string field"],"exampleFix":"// before: field 'payload' typed as Number feeds the JSON source field\n// after: force String upstream\n// Select Values: payload -> String, or in a UDJC/Script:\nrow.payload = row.payload == null ? null : row.payload.toString();","handlingStrategy":"type-guard","validationCode":"// in a preceding step or User Defined Java Class:\nif (!(jsonValue instanceof String) && !(jsonValue instanceof byte[])) {\n  throw new IllegalStateException(\"JSON source field must be String or byte[], got: \" + jsonValue.getClass());\n}","typeGuard":"boolean isValidJsonSource(Object v) {\n  return v instanceof String || v instanceof byte[];\n}","tryCatchPattern":"try { /* index rows */ } catch (KettleStepException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"NoJsonFieldFormat\")) {\n    log.error(\"Check the JSON field's stream type; must be String or Binary\");\n  }\n}","preventionTips":["Set the JSON field's metadata type to String in an upstream Select Values step","Prefer building documents from fields over raw JSON when types vary","Preview the stream in Spoon and check field types before running"],"tags":["elasticsearch","kettle","type-mismatch","json"],"backgroundTag":"incompatible-source-type","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"}