apache/seatunnel · error · IllegalArgumentException
Value is not a supported long
Error message
Value is not a supported long
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-amazondocumentdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/amazondocumentdb/serialize/DocumentDBItemDeserializer.java:154
long number = value.asNumber().longValue();
if (number < minimum || number > maximum) {
throw new IllegalArgumentException("Integer value is out of range");
}
return (int) number;
}
private static long checkedLong(BsonValue value) {
if (value.isInt32() || value.isInt64()) {
return value.asNumber().longValue();
}
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()));View on GitHub (pinned to cf67b549a7)
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.
Example fix
// before
{"count": "123"} // string in BSON, schema says bigint
// after
{"count": NumberLong(123)} Defensive patterns
Strategy: type-guard
Validate before calling
if (!(bsonValue.isInt32() || bsonValue.isInt64() || bsonValue.isDouble())) {
throw new IllegalArgumentException("expected numeric BSON type, got: " + bsonValue.getBsonType());
} Type guard
boolean isLongLike(org.bson.BsonValue v) {
return v != null && (v.isInt32() || v.isInt64() || v.isDouble());
} Prevention
- 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.
When it happens
Trigger: A BSON field mapped to SeaTunnel BIGINT contains a string ("123"), Decimal128, boolean, or nested document instead of int32/int64/double.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/74648f2e64027a73.
Report an issue: GitHub.