apache/seatunnel · error · IllegalArgumentException

Infinite Decimal128 values are not supported

Error message

Infinite Decimal128 values are not supported

What it means

DocumentDBItemDeserializer.convertDecimal rejects non-finite Decimal128 values (NaN, +Infinity, -Infinity) with IllegalArgumentException because SeaTunnel DECIMAL cannot represent them. The javadoc notes the deserializer deliberately fails instead of emitting null, so malformed data isn't masked as BSON null.

Solutions

  1. Clean the source data: find offending docs with a match query on the non-finite values and correct/remove them.
  2. Avoid writing non-finite values upstream (guard $divide denominators in aggregations).
  3. If non-finite values are legitimate, remap the column to DOUBLE, which can represent them (subject to checkedLong-style handling elsewhere).

Example fix

// before
{"amount": NumberDecimal("Infinity")}   // schema DECIMAL
// after
{"amount": NumberDecimal("99999999.99")}  // or clean via match query
Defensive patterns

Strategy: validation

Validate before calling

if (bsonValue.isDecimal128() && !bsonValue.asDecimal128().decimal128Value().isFinite()) {
    throw new IllegalArgumentException("non-finite Decimal128 value found; clean source data first");
}

Type guard

boolean isFiniteDecimal(org.bson.BsonValue v) {
    return v.isDecimal128() && v.asDecimal128().decimal128Value().isFinite();
}

Try / catch

try {
    // read decimal column
} catch (IllegalArgumentException e) {
    log.error("Non-finite Decimal128 in source", e);
}

Prevention

When it happens

Trigger: A Decimal128 field mapped to SeaTunnel DECIMAL contains NaN or Infinity, produced by upstream writes of NumberDecimal("Infinity") or division results.

Common situations: Aggregations ($divide by zero) wrote Infinity into DocumentDB; application code wrote NaN; legacy data predating the schema constraint.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/serialize/DocumentDBItemDeserializer.java:164

        }
        if (value.isDouble()) {
            double number = value.asNumber().doubleValue();
            if (number < Long.MIN_VALUE || number > Long.MAX_VALUE) {
                throw new IllegalArgumentException("Long value is out of range");
            }
            return value.asNumber().longValue();
        }
        throw new IllegalArgumentException("Value is not a supported long");
    }

    /**
     * Applies the configured scale and rejects precision overflow instead of silently emitting
     * {@code null}, which would make malformed source data indistinguishable from BSON null.
     */
    private static BigDecimal convertDecimal(DecimalType type, BsonValue value) {
        Decimal128 decimal128 = value.asDecimal128().decimal128Value();
        if (!decimal128.isFinite()) {
            throw new IllegalArgumentException("Infinite Decimal128 values are not supported");
        }
        BigDecimal decimal =
                decimal128.bigDecimalValue().setScale(type.getScale(), RoundingMode.HALF_UP);
        if (decimal.precision() > type.getPrecision()) {
            throw new IllegalArgumentException(
                    String.format(
                            "Decimal precision %d exceeds configured precision %d",
                            decimal.precision(), type.getPrecision()));
        }
        return decimal;
    }

    private static String convertString(BsonValue value) {
        if (value.isString()) {
            return value.asString().getValue();
        }
        if (value.isObjectId()) {
            return value.asObjectId().getValue().toHexString();

View on GitHub (pinned to cf67b549a7)