apache/flink · error · java.lang.IllegalStateException
Illegal Json Data...
Error message
Illegal Json Data...
What it means
IllegalStateException from RowNestedConverter.convertNotNull (the projected/nested-row path used when only selected nested fields are extracted) when the token is not START_OBJECT. It is the nested-projection counterpart of error 1375: the JSON fragment being projected must be an object, but a scalar/array was found.
Source
Thrown at flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonParserToRowDataConverters.java:608
path[i] = fieldIndex;
}
outputPosToPath.put(pos, path);
}
}
private class RowNestedConverter extends ProjectedConverter {
private static final long serialVersionUID = 1L;
private final Map<String, ProjectedConverter> fieldConverters = new HashMap<>();
// Keep path here for fallback to get nested field from a converted row field.
private final Map<Integer, String[]> outputPosToPath = new HashMap<>();
@Override
public void convertNotNull(JsonParser jp, GenericRowData outputRow) throws IOException {
if (jp.currentToken() != JsonToken.START_OBJECT) {
throw new IllegalStateException("Illegal Json Data...");
}
int arity = fieldConverters.size();
int cnt = 0;
jp.nextToken();
while (jp.currentToken() != JsonToken.END_OBJECT) {
if (cnt >= arity) {
skipToNextField(jp);
continue;
}
String fieldName = jp.getText();
jp.nextToken();
ProjectedConverter converter = fieldConverters.get(fieldName);
if (converter != null) {
converter.convert(jp, outputRow);
jp.nextToken();
cnt++;
} else {
skipToNextField(jp);View on GitHub (pinned to 2f3c205e92)
Solutions
- Align DDL nested types with the real payload shape (nested ROW fields must be JSON objects)
- Fix producer output for that nested field
- With ignore-parse-errors=true the record is skipped rather than failing (verify policy fit first)
Example fix
-- before: info ROW<name STRING> but data is "info": "n/a" SELECT info.name FROM t -- after: model it as what it is info STRING
Defensive patterns
Strategy: try-catch
Validate before calling
JsonNode n = mapper.readTree(sample).get("info");
if (n != null && !n.isObject()) throw new IllegalStateException("projected nested field source must be an object"); Try / catch
catch (IllegalStateException e) {
if (e.getMessage().contains("Illegal Json Data")) {
// nested projection hit a non-object; align nested schema or skip row
}
} Prevention
- Validate nested-field shapes on samples when using nested projections
- Keep nested ROW columns mapped to real JSON objects in producer code
When it happens
Trigger: Using nested-field projection (e.g., SELECT info.name from a ROW-typed or json_derived column) where the projected source in the payload is not a JSON object — e.g., "info": "N/A" or "info": [..].
Common situations: Same shape-mismatch family as 1372/1374/1375, hit specifically when the optimizer prunes to nested fields and the nested converter runs instead of the full row converter.
Related errors
- Illegal JSON object data...
- Failed to deserialize JSON '%s'.
- Illegal JSON array data...
- Illegal JSON map data...
- Fail to deserialize at field: %s.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/c6110fc90461fb4b.
Report an issue: GitHub.