apache/beam · error · UnsupportedRowJsonException
Expected JSON object for field '{name}'. Instead got {jsonNo
Error message
Expected JSON object for field '{name}'. Instead got {jsonNodeType} What it means
For MAP-typed schema fields, jsonObjectToMap requires the JSON value to be an object whose keys become map keys. A different JSON node type causes UnsupportedRowJsonException that names the encountered Jackson node type.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java:387
+ "'. Instead got "
+ arrayFieldValue.jsonNodeType().name());
}
return arrayFieldValue
.jsonArrayElements()
.map(
jsonArrayElement ->
extractJsonNodeValue(
FieldValue.of(
arrayFieldValue.name() + "[]",
arrayFieldValue.arrayElementType(),
jsonArrayElement)))
.collect(toImmutableList());
}
private Map<String, Object> jsonObjectToMap(FieldValue mapFieldValue) {
if (!mapFieldValue.isJsonObject()) {
throw new UnsupportedRowJsonException(
"Expected JSON object for field '"
+ mapFieldValue.name()
+ "'. Instead got "
+ mapFieldValue.jsonNodeType().name());
}
Map<String, Object> result = new HashMap<>();
Iterator<Map.Entry<String, JsonNode>> fields = mapFieldValue.jsonValue().fields();
while (fields.hasNext()) {
Map.Entry<String, JsonNode> field = fields.next();
String key = field.getKey();
JsonNode value = field.getValue();
Object extractedValue =
extractJsonNodeValue(
FieldValue.of(
mapFieldValue.name() + "['" + key + "']", mapFieldValue.mapValueType(), value));
View on GitHub (pinned to 12126d8942)
Solutions
- Emit the map field as a JSON object, e.g. "props": {"k": "v"}
- Change the schema field type (e.g. to ARRAY<ROW<k,v>>) to match the payload
- Convert list-of-pairs JSON to an object before parsing
- Catch UnsupportedRowJsonException and route bad records to error handling
Example fix
// before
{"props": [{"k":"a","v":1}]}
// after
{"props": {"a": 1}} Defensive patterns
Strategy: validation
Validate before calling
JsonNode n = json.get("mapField");
if (n != null && !n.isObject()) throw new IllegalArgumentException("Map field must be a JSON object, got " + n.getNodeType()); Try / catch
try { Row r = RowJsonUtils.jsonToRow(mapper, json); } catch (RowJson.UnsupportedRowJsonException e) { /* handle */ } Prevention
- Serialize maps as JSON objects, not arrays of pairs
- Document map encoding for producers
- Validate payloads against MAP-typed fields
When it happens
Trigger: jsonToRow where a MAP<...> schema field receives a non-object JSON value, e.g. "props": "k=v" or an array instead of an object.
Common situations: Producers serializing maps as lists of key/value pairs; schema changed from array to map; generic JSON ingestion with mismatched reader schema.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Non-nullable field '{name}' is not present in the JSON objec
- Expected JSON object for field '{name}'. Unable to convert '
- Expected JSON array for field '{name}'. Instead got {jsonNod
- Unable to get value from field '{name}'. Schema type '{typeN
- Unable to parse Row
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/41eb2087226139d8.
Report an issue: GitHub.