apache/seatunnel · error · SeaTunnelRuntimeException

COMMON-02

COMMON-02

Error message

Json JSON convert/parse '<payload>' operation failed.

What it means

The Json serialization schema failed to convert a SeaTunnelRow into a JsonNode and/or write it out as a JSON string. Any Throwable during runtimeConverter.convert(mapper, node, row) or mapper.writeValueAsString triggers COMMON-02 JSON_OPERATION_FAILED carrying row.toString() as the payload. Unlike deserialization there is no ignoreParseErrors escape hatch, so this fails the record/job.

Source

Thrown at seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonSerializationSchema.java:93

                        .createConverter(checkNotNull(rowType));
        this.charset = StandardCharsets.UTF_8;
    }

    {
        mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
    }

    @Override
    public byte[] serialize(SeaTunnelRow row) {
        if (node == null) {
            node = mapper.createObjectNode();
        }

        try {
            runtimeConverter.convert(mapper, node, row);
            return mapper.writeValueAsString(node).getBytes(charset);
        } catch (Throwable t) {
            throw CommonError.jsonOperationError(FORMAT, row.toString(), t);
        }
    }

    public JsonNode convert(SeaTunnelRow row) {
        if (node == null) {
            node = mapper.createObjectNode();
        }

        try {
            return runtimeConverter.convert(mapper, node, row);
        } catch (Exception e) {
            throw CommonError.jsonOperationError(FORMAT, row.toString(), e);
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect row.toString() in the message and fix the offending field value/type upstream before serialization
  2. Ensure the SeaTunnelRowType of the producing source matches types the JSON format supports
  3. Clean/coerce NaN, Infinity, and unsupported nested types in a transform before the sink
  4. Capture the wrapped cause (getCause()) to pinpoint the failing converter

Example fix

// before
row.setField(1, Double.NaN); // writeValueAsString fails
// after
row.setField(1, Double.isNaN(value) ? null : value); // or sanitize upstream
Defensive patterns

Strategy: validation

Validate before calling

// verify each field value is serializable-safe before serialize()
for (int i = 0; i < rowType.getTotalFields(); i++) {
    Object v = row.getField(i);
    if (v instanceof Double d && (d.isNaN() || d.isInfinite()))
        throw new IllegalArgumentException("non-serializable double at field " + rowType.getFieldName(i));
}

Type guard

static boolean isJsonSerializable(SeaTunnelRow row, SeaTunnelRowType rowType) {
    for (int i = 0; i < rowType.getTotalFields(); i++) {
        Object v = row.getField(i);
        if (v == null) continue;
        if (v instanceof Double d && (d.isNaN() || d.isInfinite())) return false;
    }
    return true;
}

Try / catch

try {
    byte[] out = schema.serialize(row);
} catch (SeaTunnelRuntimeException e) {
    log.error("Serialization failed for row {} cause {}", row, e.getCause());
    throw e; // serialization has no skip flag; fix the row
}

Prevention

When it happens

Trigger: JsonSerializationSchema.serialize(SeaTunnelRow row) throws when a field value cannot be mapped by the runtime converter to the target JsonNode (unsupported field type, null in a non-nullable position) or Jackson fails to serialize the node (e.g. NaN/Infinity doubles, cyclic values).

Common situations: Sink row contains a type the JSON converter does not support (e.g. unusual Map/Array types); null values where the schema disallows them; floating-point NaN values produced by upstream transforms; charset/serialization edge cases.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/ac16a4fef03d1e30. Report an issue: GitHub.