{"record":{"id":"ea4e087b34ff246f","repo":"apache/seatunnel","slug":"infinite-decimal128-values-are-not-supported","errorCode":null,"errorMessage":"Infinite Decimal128 values are not supported","messagePattern":"Infinite Decimal128 values are not supported","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/serialize/DocumentDBItemDeserializer.java","lineNumber":164,"sourceCode":"        }\n        if (value.isDouble()) {\n            double number = value.asNumber().doubleValue();\n            if (number < Long.MIN_VALUE || number > Long.MAX_VALUE) {\n                throw new IllegalArgumentException(\"Long value is out of range\");\n            }\n            return value.asNumber().longValue();\n        }\n        throw new IllegalArgumentException(\"Value is not a supported long\");\n    }\n\n    /**\n     * Applies the configured scale and rejects precision overflow instead of silently emitting\n     * {@code null}, which would make malformed source data indistinguishable from BSON null.\n     */\n    private static BigDecimal convertDecimal(DecimalType type, BsonValue value) {\n        Decimal128 decimal128 = value.asDecimal128().decimal128Value();\n        if (!decimal128.isFinite()) {\n            throw new IllegalArgumentException(\"Infinite Decimal128 values are not supported\");\n        }\n        BigDecimal decimal =\n                decimal128.bigDecimalValue().setScale(type.getScale(), RoundingMode.HALF_UP);\n        if (decimal.precision() > type.getPrecision()) {\n            throw new IllegalArgumentException(\n                    String.format(\n                            \"Decimal precision %d exceeds configured precision %d\",\n                            decimal.precision(), type.getPrecision()));\n        }\n        return decimal;\n    }\n\n    private static String convertString(BsonValue value) {\n        if (value.isString()) {\n            return value.asString().getValue();\n        }\n        if (value.isObjectId()) {\n            return value.asObjectId().getValue().toHexString();","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/serialize/DocumentDBItemDeserializer.java#L146-L182","documentation":"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.","triggerScenarios":"A Decimal128 field mapped to SeaTunnel DECIMAL contains NaN or Infinity, produced by upstream writes of NumberDecimal(\"Infinity\") or division results.","commonSituations":"Aggregations ($divide by zero) wrote Infinity into DocumentDB; application code wrote NaN; legacy data predating the schema constraint.","solutions":["Clean the source data: find offending docs with a match query on the non-finite values and correct/remove them.","Avoid writing non-finite values upstream (guard $divide denominators in aggregations).","If non-finite values are legitimate, remap the column to DOUBLE, which can represent them (subject to checkedLong-style handling elsewhere)."],"exampleFix":"// before\n{\"amount\": NumberDecimal(\"Infinity\")}   // schema DECIMAL\n// after\n{\"amount\": NumberDecimal(\"99999999.99\")}  // or clean via match query","handlingStrategy":"validation","validationCode":"if (bsonValue.isDecimal128() && !bsonValue.asDecimal128().decimal128Value().isFinite()) {\n    throw new IllegalArgumentException(\"non-finite Decimal128 value found; clean source data first\");\n}","typeGuard":"boolean isFiniteDecimal(org.bson.BsonValue v) {\n    return v.isDecimal128() && v.asDecimal128().decimal128Value().isFinite();\n}","tryCatchPattern":"try {\n    // read decimal column\n} catch (IllegalArgumentException e) {\n    log.error(\"Non-finite Decimal128 in source\", e);\n}","preventionTips":["Guard $divide aggregations against zero denominators so Infinity never lands in DocumentDB.","Scan collections for NaN/Infinity Decimal128 values with a match query before running jobs.","Use DECIMAL columns only where finite values are guaranteed; prefer DOUBLE otherwise."],"tags":["serialization","decimal128","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}