apache/beam · error · IllegalArgumentException
Unable to serialize row: {row}
Error message
Unable to serialize row: {row} What it means
RowJsonUtils.rowToJson serializes a Beam Row to a JSON string and wraps JsonProcessingException into IllegalArgumentException('Unable to serialize row: <row>'). Serialization failures are typically Row values that the RowJson serializer cannot represent (see writeValue's unsupported types) or Jackson generation failures.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJsonUtils.java:148
return objectMapper;
}
public static Row jsonToRow(ObjectMapper objectMapper, String jsonString) {
try {
return objectMapper.readValue(jsonString, Row.class);
} catch (JsonParseException | JsonMappingException jsonException) {
throw new UnsupportedRowJsonException("Unable to parse Row", jsonException);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to parse json object: " + jsonString, e);
}
}
public static String rowToJson(ObjectMapper objectMapper, Row row) {
try {
return objectMapper.writeValueAsString(row);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Unable to serialize row: " + row, e);
}
}
}
View on GitHub (pinned to 12126d8942)
Solutions
- Check getCause() (JsonProcessingException) for the exact field/value that failed
- Convert unsupported field types to supported ones (base types, String) before serializing
- Use a RowJson ObjectMapper configured for Row serialization
- Catch IllegalArgumentException around rowToJson and skip/re-encode offending rows
Example fix
try {
String json = RowJsonUtils.rowToJson(mapper, row);
} catch (IllegalArgumentException e) {
LOG.error("Cannot serialize row: {}", e.getMessage(), e.getCause());
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check: ensure all field values map to supported writer types
row.getSchema().getFields().forEach(f -> {
if (!SUPPORTED_WRITER_TYPES.contains(f.getType().getTypeName())) throw new IllegalStateException("Unsupported: " + f.getName());
}); Try / catch
try { String s = RowJsonUtils.rowToJson(mapper, row); } catch (IllegalArgumentException e) { /* e.getCause() is JsonProcessingException naming the failing field */ } Prevention
- Avoid NaN/Infinite values in Row fields
- Convert unsupported logical types before serializing
- Test serialization whenever the schema changes
When it happens
Trigger: rowToJson(objectMapper, row) where the Row contains fields the serializer cannot write (unsupported schema types, illegal values) or a Jackson generation problem occurs mid-write.
Common situations: Rows containing logical/custom types unsupported by the writer; NaN/infinite doubles; schema evolution producing types the serializer switch doesn't cover.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- Unsupported field type: {type}
- Cannot provide SerializableCoder because {} does not impleme
- Java Serialization may be non-deterministic.
- cannot encode a null String
- cannot encode a null Integer
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/94392c101754a3fc.
Report an issue: GitHub.