{"record":{"id":"77428b06bd59389b","repo":"t8y2/dbx","slug":"name-is-outside-the-supported-integer-rang","errorCode":null,"errorMessage":"\" + name + \" is outside the supported integer range","messagePattern":"\" \\+ name \\+ \" is outside the supported integer range","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java","lineNumber":1541,"sourceCode":"        for (JsonElement element : offsetArray) {\n            if (!element.isJsonObject()) {\n                throw new IllegalArgumentException(\"each offset must be an object\");\n            }\n            JsonObject value = element.getAsJsonObject();\n            int partition = nonNegativeExactInt(value, \"partition\");\n            long offset = nonNegativeExactLong(value, \"offset\");\n            TopicPartition topicPartition = new TopicPartition(topic, partition);\n            if (offsets.put(topicPartition, new OffsetAndMetadata(offset)) != null) {\n                throw new IllegalArgumentException(\"duplicate partition in offsets: \" + partition);\n            }\n        }\n        return offsets;\n    }\n\n    private static int nonNegativeExactInt(JsonObject object, String name) {\n        long value = nonNegativeExactLong(object, name);\n        if (value > Integer.MAX_VALUE) {\n            throw new IllegalArgumentException(name + \" is outside the supported integer range\");\n        }\n        return (int) value;\n    }\n\n    private static long nonNegativeExactLong(JsonObject object, String name) {\n        JsonElement element = object.get(name);\n        if (element == null || !element.isJsonPrimitive() || !element.getAsJsonPrimitive().isNumber()) {\n            throw new IllegalArgumentException(name + \" must be a non-negative integer\");\n        }\n        try {\n            java.math.BigDecimal decimal = element.getAsBigDecimal();\n            if (decimal.signum() < 0 || decimal.stripTrailingZeros().scale() > 0) {\n                throw new IllegalArgumentException(name + \" must be a non-negative integer\");\n            }\n            return decimal.longValueExact();\n        } catch (ArithmeticException error) {\n            throw new IllegalArgumentException(name + \" is outside the supported integer range\", error);\n        }","sourceCodeStart":1523,"sourceCodeEnd":1559,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java#L1523-L1559","documentation":"nonNegativeExactInt converts a validated non-negative long into an int for the Kafka partition number; values above Integer.MAX_VALUE cannot fit and throw IllegalArgumentException \"<name> is outside the supported integer range\" (KafkaAgent.java:1541).","triggerScenarios":"Supplying a \"partition\" (or any field routed through nonNegativeExactInt) larger than 2147483647, e.g. passing a 64-bit offset value into the partition field.","commonSituations":"Swapping partition/offset values in the payload; computing partition from a hash stored as long; copying an offset value into the partition slot.","solutions":["Ensure the partition value fits in a 32-bit int (0..2147483647)","Swap the values if partition and offset were transposed","Clamp or reject out-of-range values client-side before the call"],"exampleFix":"// before\n{\"partition\": 5000000000, \"offset\": 100}\n// after\n{\"partition\": 0, \"offset\": 100}","handlingStrategy":"validation","validationCode":"if (!Number.isInteger(partition) || partition < 0 || partition > 2147483647) throw new Error('invalid partition');","typeGuard":"function isValidPartition(p) { return Number.isInteger(p) && p >= 0 && p <= 2147483647; }","tryCatchPattern":"try { agent.execute(req); } catch (e) { if (String(e.message).includes('outside the supported integer range')) { /* check partition/offset values */ } else throw e; }","preventionTips":["Keep partition values within int range","Verify field order — partition and offset are easy to swap","Range-check values derived from hashes or other long sources"],"tags":["kafka","input-validation","integer-overflow"],"backgroundTag":"integer-out-of-range","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}