{"record":{"id":"74648f2e64027a73","repo":"apache/seatunnel","slug":"value-is-not-a-supported-long","errorCode":null,"errorMessage":"Value is not a supported long","messagePattern":"Value is not a supported long","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":154,"sourceCode":"        long number = value.asNumber().longValue();\n        if (number < minimum || number > maximum) {\n            throw new IllegalArgumentException(\"Integer value is out of range\");\n        }\n        return (int) number;\n    }\n\n    private static long checkedLong(BsonValue value) {\n        if (value.isInt32() || value.isInt64()) {\n            return value.asNumber().longValue();\n        }\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()));","sourceCodeStart":136,"sourceCodeEnd":172,"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#L136-L172","documentation":"checkedLong's final branch throws IllegalArgumentException(\"Value is not a supported long\") when the BsonValue is neither int32, int64, nor double — i.e. it has no numeric representation (string, decimal128 not routed here, boolean, object, etc.) but is being read as a long. It's a strict type check preventing bogus numeric coercion.","triggerScenarios":"A BSON field mapped to SeaTunnel BIGINT contains a string (\"123\"), Decimal128, boolean, or nested document instead of int32/int64/double.","commonSituations":"Schema drift: numbers stored as strings in newer documents; field accidentally mapped as BIGINT while source stores Decimal128; untyped pipeline outputs returning documents where scalars were expected.","solutions":["Fix the source collection to store actual numeric types (int32/int64/double) for the field.","Change the SeaTunnel column type to DECIMAL if the source stores Decimal128 values.","Use a transform to cast/coerce string numerics to numbers before deserialization, if available."],"exampleFix":"// before\n{\"count\": \"123\"}        // string in BSON, schema says bigint\n// after\n{\"count\": NumberLong(123)}","handlingStrategy":"type-guard","validationCode":"if (!(bsonValue.isInt32() || bsonValue.isInt64() || bsonValue.isDouble())) {\n    throw new IllegalArgumentException(\"expected numeric BSON type, got: \" + bsonValue.getBsonType());\n}","typeGuard":"boolean isLongLike(org.bson.BsonValue v) {\n    return v != null && (v.isInt32() || v.isInt64() || v.isDouble());\n}","tryCatchPattern":null,"preventionTips":["Enforce BSON field types in the application layer that writes to DocumentDB.","Audit collections for type drift (mixed string/numeric fields) before mapping to BIGINT.","Use Decimal128-aware column types when source stores NumberDecimal."],"tags":["serialization","type-mismatch","bson"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}