{"record":{"id":"6b7491f195a819ee","repo":"apache/seatunnel","slug":"integer-value-is-out-of-range","errorCode":null,"errorMessage":"Integer value is out of range","messagePattern":"Integer value is out of range","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":138,"sourceCode":"            throw e;\n        } catch (RuntimeException e) {\n            SeaTunnelRuntimeException error = conversionError(field, type);\n            error.initCause(e);\n            throw error;\n        }\n    }\n\n    private static boolean isNull(BsonValue value) {\n        return value == null\n                || value.isNull()\n                || value.getBsonType() == BsonType.UNDEFINED\n                || (value.isDecimal128() && value.asDecimal128().getValue().isNaN());\n    }\n\n    private static int checkedInteger(BsonValue value, int minimum, int maximum) {\n        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","sourceCodeStart":120,"sourceCodeEnd":156,"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#L120-L156","documentation":"DocumentDBItemDeserializer.checkedInteger converts a BSON numeric value to int for SeaTunnel INT columns and throws IllegalArgumentException if the numeric value falls outside [minimum, maximum] (e.g. Integer.MIN/MAX_VALUE). This prevents silent truncation when converting long/double/decimal BSON values to Java int.","triggerScenarios":"A BSON field mapped to SeaTunnel INT contains a value like 3_000_000_000 (int64 or double) exceeding Integer.MAX_VALUE, or below Integer.MIN_VALUE.","commonSituations":"Source collection holds large counters/IDs stored as int64 but the SeaTunnel schema declares the column as int; a decimal value rounds to a number outside int range.","solutions":["Widen the SeaTunnel column type from int to bigint in the schema so large values fit.","Fix the source data or filter out rows with out-of-range values via the match query.","If conversion is expected to be lossy, pre-clamp values in the source or a transform stage."],"exampleFix":"// before\n{\"name\": \"count\", \"type\": \"int\"}   // source value 3,000,000,000\n// after\n{\"name\": \"count\", \"type\": \"bigint\"}","handlingStrategy":"validation","validationCode":"long v = bsonValue.asNumber().longValue();\nif (v < Integer.MIN_VALUE || v > Integer.MAX_VALUE) {\n    throw new IllegalArgumentException(\"value does not fit int column: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    // deserialize row\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"out of range\")) {\n        log.error(\"INT column overflow from DocumentDB value\", e);\n    }\n}","preventionTips":["Match SeaTunnel column types to actual BSON numeric magnitude (bigint for anything near 2^31).","Profile source data max/min before declaring int columns.","Add upper-bound checks in upstream writers if counters can exceed int range."],"tags":["serialization","type-conversion","numeric-overflow"],"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-14T11:17:12.474Z"}