apache/seatunnel · error · RuntimeException

Invalid bytes field

Error message

Invalid bytes field

What it means

For BYTES-typed fields the Debezium row converter calls Jackson's value.binaryValue() to turn (base64) textual content into raw bytes. If that conversion fails (malformed base64 or non-decodable content), the converter wraps the IOException in RuntimeException("Invalid bytes field").

Solutions

  1. Set Debezium's binary.handling.mode=base64 (or align modes) so payloads are valid base64
  2. Validate that the JSON string for bytes fields decodes as base64 before ingestion
  3. Check for schema evolution where the column type changed from bytes to text and update the SeaTunnel schema accordingly
  4. Fix corrupted/upstream-produced payloads at the source

Example fix

// before
"binary.handling.mode": "hex"   // consumer expects base64
// after
"binary.handling.mode": "base64"
Defensive patterns

Strategy: validation

Validate before calling

JsonNode v = payload.get("bytesField");
if (v != null && v.isTextual()) {
    try { java.util.Base64.getDecoder().decode(v.asText()); }
    catch (IllegalArgumentException e) { throw new IllegalArgumentException("bytesField is not valid base64"); }
}

Try / catch

try {
    row = converter.parse(payload);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("Invalid bytes field")) {
        log.error("Binary field payload is not decodable; check binary.handling.mode", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: getValue() on a BYTES field whose JSON node is a string that is not valid base64, or otherwise not convertible to a byte array.

Common situations: Debezium binary.handling.mode mismatch (base64 vs. hex vs. as-string) between producer and consumer; schema evolution turning a bytes column into a text column; replayed or hand-written test payloads with fake binary values.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/debezium/DebeziumRowConverter.java:114

                                new BigInteger(value.binaryValue()),
                                ((DecimalType) dataType).getScale());
                    } catch (Exception e) {
                        throw new RuntimeException("Invalid bytes for Decimal field", e);
                    }
                }
                if (value.has(DECIMAL_SCALE_KEY)) {
                    return new BigDecimal(
                            new BigInteger(value.get(DECIMAL_VALUE_KEY).binaryValue()),
                            value.get(DECIMAL_SCALE_KEY).intValue());
                }
                return new BigDecimal(value.asText());
            case STRING:
                return value.asText();
            case BYTES:
                try {
                    return value.binaryValue();
                } catch (IOException e) {
                    throw new RuntimeException("Invalid bytes field", e);
                }
            case DATE:
                String dateStr = value.asText();
                if (value.canConvertToLong()) {
                    return LocalDate.ofEpochDay(Long.parseLong(dateStr));
                }
                DateTimeFormatter dateFormatter = fieldFormatterMap.get(fieldName);
                if (dateFormatter == null) {
                    dateFormatter = DateUtils.matchDateFormatter(dateStr);
                    fieldFormatterMap.put(fieldName, dateFormatter);
                }
                if (dateFormatter == null) {
                    throw new SeaTunnelJsonFormatException(
                            CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,
                            String.format(
                                    "SeaTunnel can not parse this date format [%s] of field [%s]",
                                    dateStr, fieldName));
                }

View on GitHub (pinned to cf67b549a7)