apache/seatunnel · error · SeaTunnelJsonFormatException

CONVERT_TO_CONNECTOR_TYPE_ERROR_SIMPLE

CONVERT_TO_CONNECTOR_TYPE_ERROR_SIMPLE

Error message

Failed to deserialize JSON '%s'.

What it means

convertBytes wraps the raw JSON parse step of Maxwell message handling: jsonDeserializer attempts to parse the byte[] into a JsonNode. If parsing fails and ignoreParseErrors is false, the raw bytes are wrapped in a SeaTunnelJsonFormatException (CONVERT_TO_CONNECTOR_TYPE_ERROR_SIMPLE) with the original exception attached.

Source

Thrown at seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/maxwell/MaxWellJsonDeserializationSchema.java:198

        } else {
            if (!ignoreParseErrors) {
                throw new SeaTunnelJsonFormatException(
                        CommonErrorCode.UNSUPPORTED_DATA_TYPE,
                        format(
                                "Unknown \"type\" value \"%s\". The MaxWell JSON message is '%s'",
                                type, new String(message)));
            }
        }
    }

    private JsonNode convertBytes(byte[] message) {
        try {
            return jsonDeserializer.deserializeToJsonNode(message);
        } catch (Exception t) {
            if (ignoreParseErrors) {
                return null;
            }
            throw new SeaTunnelJsonFormatException(
                    CommonErrorCode.CONVERT_TO_CONNECTOR_TYPE_ERROR_SIMPLE,
                    String.format("Failed to deserialize JSON '%s'.", new String(message)),
                    t);
        }
    }

    private SeaTunnelRow convertJsonNode(JsonNode root) {
        return jsonDeserializer.convertToRowData(root);
    }

    private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType physicalDataType) {
        // MaxWell JSON contains other information, e.g. "ts", "sql", but we don't need them
        return physicalDataType;
    }

    // ------------------------------------------------------------------------------------------
    // Builder
    // ------------------------------------------------------------------------------------------

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Enable format.ignore-parse-errors=true so bad records are skipped instead of failing the job
  2. Inspect the raw message (printed in the error) and clean/repair the topic or repartition data
  3. Ensure the source points at the correct Maxwell JSON topic and that no tombstones/nulls reach the parser
  4. Validate producer encoding (UTF-8) and message completeness upstream

Example fix

// before: job fails on malformed kafka record
// after
source {
  Kafka {
    ...
    format = json
    format.ignore-parse-errors = true
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate bytes are valid UTF-8 JSON before deserialization
try {
    new ObjectMapper().readTree(message);
} catch (IOException e) {
    log.warn("Skipping non-JSON kafka record");
    return;
}

Try / catch

try {
    schema.deserialize(message, out);
} catch (SeaTunnelJsonFormatException e) {
    if (e.getCause() != null) log.warn("Malformed maxwell json skipped: {}", e.getCause().getMessage());
}

Prevention

When it happens

Trigger: deserialize → convertBytes is handed byte[] that is not valid JSON (truncated record, non-UTF8 bytes, a tombstone/null payload mishandled upstream, or a completely different serialization format in the topic).

Common situations: Kafka topic polluted by other producers; compacted topics with tombstone records; message size limits truncating payloads; charset/encoding corruption during transport; users pointing the CDC source at the wrong topic.

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


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