apache/seatunnel · error · SeaTunnelRuntimeException
COMMON-02
COMMON-02
Error message
<identifier> JSON convert/parse '<payload>' operation failed.
What it means
ClickHouse sink's StringInjectFunction.injectFields() writes a Java field value into a JDBC PreparedStatement. For nested ClickHouse types (e.g. multidimensional arrays of Doubles) it parses the value's string form with Jackson (MAPPER.readValue). If the string is not valid/expected JSON, JsonProcessingException is caught and rethrown as CommonError.jsonOperationError("Clickhouse", value, e) (COMMON-02).
Source
Thrown at seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/inject/StringInjectFunction.java:53
throws SQLException {
try {
if ("Point".equals(fieldType)) {
statement.setObject(
index, MAPPER.readValue(replace(value.toString()), double[].class));
} else if ("Ring".equals(fieldType)) {
statement.setObject(
index, MAPPER.readValue(replace(value.toString()), double[][].class));
} else if ("Polygon".equals(fieldType)) {
statement.setObject(
index, MAPPER.readValue(replace(value.toString()), double[][][].class));
} else if ("MultiPolygon".equals(fieldType)) {
statement.setObject(
index, MAPPER.readValue(replace(value.toString()), double[][][][].class));
} else {
statement.setString(index, value.toString());
}
} catch (JsonProcessingException e) {
throw CommonError.jsonOperationError("Clickhouse", value.toString(), e);
}
}
@Override
public boolean isCurrentFieldType(String fieldType) {
if ("String".equals(fieldType)
|| "Int128".equals(fieldType)
|| "UInt128".equals(fieldType)
|| "Int256".equals(fieldType)
|| "UInt256".equals(fieldType)
|| "Point".equals(fieldType)
|| "Ring".equals(fieldType)
|| "Polygon".equals(fieldType)
|| "MultiPolygon".equals(fieldType)) {
this.fieldType = fieldType;
return true;
}
return false;View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the '<payload>' in the error message and fix the upstream data to be valid JSON matching the target ClickHouse type (e.g. [[1.0,2.0]] for double[][]).
- Add a transform upstream to sanitize/normalize nested array values into strict JSON before the sink.
- Change the ClickHouse column type (or schema mapping) so the value uses setString instead of JSON parsing if it's plain text.
- Check the wrapped JsonProcessingException cause to identify the exact malformed position.
Example fix
// before (value) "[[1.0, 2.0], [3.0]]' // trailing quote, invalid JSON // after "[[1.0,2.0],[3.0]]"
Defensive patterns
Strategy: validation
Validate before calling
java // Pre-validate nested array values are strict JSON before the ClickHouse sink String s = value.toString(); new ObjectMapper().readTree(s); // throws if not valid JSON — validate upstream
Try / catch
java
try {
injectFunction.injectFields(statement, index, value, fieldType);
} catch (SeaTunnelException e) {
if (e.getMessage().contains("JSON convert/parse")) {
// log payload; sanitize or dead-letter the record
} else { throw e; }
} Prevention
- Emit nested arrays as strict JSON (double quotes, no trailing commas) from upstream.
- Sanitize values with a transform before the ClickHouse sink.
- Match ClickHouse column types to actual payload shapes so setString is used for plain text.
- Spot-check source connector output for JSON validity in staging.
When it happens
Trigger: Injecting a String field into a ClickHouse column backed by StringInjectFunction where the value must be parsed as JSON (e.g. double[][][][]) but the value's toString() is not parseable JSON — malformed arrays, single quotes, unquoted strings, or non-array scalars.
Common situations: Upstream data contains non-JSON strings (e.g. '[1,2,' truncated, or "1.0" where a nested array is expected); values serialized with single quotes or Python-style repr; encoding/escaping issues from a source connector.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- COMMON_SQL_OPERATION_FAILED
- COMMON_FLUSH_DATA_FAILED
- array inject error, unsupported data type: " + type
- Failed to execute query: %s
- Failed to convert row to JSON
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/5a7e77628a5f6e67.
Report an issue: GitHub.