apache/seatunnel · error · SeaTunnelRuntimeException

COMMON-33

COMMON-33

Error message

The datetime format '<datetime>' of field '<field>' is not supported. Please check the datetime format.

What it means

A JSON string for a TIMESTAMP field could not be parsed with the field's formatter or any auto-matched pattern, so convertToLocalDateTime throws COMMON-33 format_datetime_error naming the value and field. The converter also refreshes/retries with DateTimeUtils.matchDateTimeFormatter before giving up.

Solutions

  1. Emit ISO-8601 datetimes from the source (yyyy-MM-dd HH:mm:ss or yyyy-MM-dd'T'HH:mm:ss)
  2. Transform the string to a supported pattern before JSON parsing
  3. Configure the format's datetime formatter option to match the producer's pattern
  4. If the value is a numeric epoch, change the field type handling or convert the number to a datetime first

Example fix

// before
{"event_time": "2024-01-05 10:00"}
// after
{"event_time": "2024-01-05 10:00:00"} // include seconds, standard pattern
Defensive patterns

Strategy: validation

Validate before calling

java.time.LocalDateTime.parse(datetimeStr); // throws if not a supported ISO pattern

Type guard

static boolean isSupportedDatetime(String s) {
    try { java.time.LocalDateTime.parse(s); return true; } catch (Exception e) { return false; }
}

Try / catch

try {
    row = jsonDeserializer.deserialize(bytes);
} catch (SeaTunnelRuntimeException e) {
    if (String.valueOf(e.getMessage()).contains("datetime format")) {
        log.warn("Bad TIMESTAMP value: {}", e.getMessage());
        return null; // or route to DLQ
    }
    throw e;
}

Prevention

When it happens

Trigger: Parsing a JSON field declared as SeaTunnel TIMESTAMP whose text (e.g. "2024-01-05 10:00", epoch millis as string, "2024-01-05T10:00:00 UTC") matches no supported datetime pattern.

Common situations: Producers emit datetimes without seconds or with timezone names Jackson patterns don't accept; numeric timestamps sent as strings where a datetime string is expected; locale-specific formats after a producer upgrade.

Related errors


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

Appendix: source

Thrown at seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/JsonToRowConverters.java:313

    private LocalDateTime convertToLocalDateTime(JsonNode jsonNode, String fieldName) {
        String datetimeStr = jsonNode.asText();

        DateTimeFormatter dateTimeFormatter = null;

        if (fieldName != null) {
            dateTimeFormatter = fieldFormatterMap.get(fieldName);
        }

        if (dateTimeFormatter == null) {
            dateTimeFormatter = DateTimeUtils.matchDateTimeFormatter(datetimeStr);
            if (fieldName != null) {
                fieldFormatterMap.put(fieldName, dateTimeFormatter);
            }
        }

        if (dateTimeFormatter == null) {
            throw CommonError.formatDateTimeError(datetimeStr, fieldName);
        }

        TemporalAccessor parsedTimestamp =
                parseDateTimeWithFormatterRefresh(datetimeStr, fieldName, dateTimeFormatter);
        LocalTime localTime = parsedTimestamp.query(TemporalQueries.localTime());
        LocalDate localDate = parsedTimestamp.query(TemporalQueries.localDate());
        return LocalDateTime.of(localDate, localTime);
    }

    /**
     * Re-resolves the formatter when the cached per-field formatter no longer matches the current
     * timestamp text. This happens when one JSON field mixes second-only and fractional-second
     * values across rows.
     */
    private TemporalAccessor parseDateTimeWithFormatterRefresh(
            String datetimeStr, String fieldName, DateTimeFormatter dateTimeFormatter) {
        try {
            return dateTimeFormatter.parse(datetimeStr);

View on GitHub (pinned to cf67b549a7)