{"record":{"id":"6638b38f6863999c","repo":"apache/cassandra","slug":"cannot-parse-64-bits-long-value-from-s","errorCode":null,"errorMessage":"Cannot parse 64-bits long value from \"%s\"","messagePattern":"Cannot parse 64-bits long value from \"(.+?)\"","errorType":"validation","errorClass":"InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java","lineNumber":1085,"sourceCode":"\n        @Override\n        public int serializedSize()\n        {\n            return 8;\n        }\n\n        @Override\n        public Long parse(String value)\n        {\n            try\n            {\n                return value == null || value.isEmpty() || value.equalsIgnoreCase(\"NULL\")\n                       ? null\n                       : Long.parseLong(value);\n            }\n            catch (NumberFormatException e)\n            {\n                throw new InvalidTypeException(\n                String.format(\"Cannot parse 64-bits long value from \\\"%s\\\"\", value));\n            }\n        }\n\n        @Override\n        public String format(Long value)\n        {\n            if (value == null) return \"NULL\";\n            return Long.toString(value);\n        }\n\n        @Override\n        public ByteBuffer serializeNoBoxing(long value, ProtocolVersion protocolVersion)\n        {\n            ByteBuffer bb = ByteBuffer.allocate(8);\n            bb.putLong(0, value);\n            return bb;\n        }","sourceCodeStart":1067,"sourceCodeEnd":1103,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L1067-L1103","documentation":"The bigint codec's parse() delegates to Long.parseLong, and any string that is not a valid signed 64-bit decimal (empty handled earlier, but garbage, overflow, or wrong type) raises NumberFormatException, which is translated into InvalidTypeException. It exists to give a codec-specific message instead of the raw JDK exception.","triggerScenarios":"Calling bigintCodec.parse(value) where value is e.g. \"1.5\", \"9223372036854775808\" (Long.MAX_VALUE+1), \"0x10\", \"12abc\", or contains whitespace/underscores.","commonSituations":"Parsing values read from CSV/JSON imports where a float or formatted number lands in a bigint column; locale-formatted numbers with thousand separators; hex or scientific notation pasted into CQL literals; overflow from counters generated in another system.","solutions":["Pass a plain base-10 integer string that fits in a signed 64-bit range (−9223372036854775808..9223372036854775807).","Round/truncate or use the decimal codec if the value legitimately has a fractional part.","Trim whitespace and strip separators before parsing.","If the value overflows 64 bits, change the column to varint (bigInteger codec) or store as text."],"exampleFix":"// before\nlongCodec.parse(\"1.5\"); // throws\n// after\nlongCodec.parse(String.valueOf((long) Double.parseDouble(\"1.5\"))); // \"1\"","handlingStrategy":"validation","validationCode":"static boolean isCqlBigintLiteral(String v) {\n    if (v == null) return false;\n    try { Long.parseLong(v.trim()); return true; }\n    catch (NumberFormatException e) { return false; }\n}","typeGuard":"boolean isLongLiteral(String v) {\n    return v != null && v.trim().matches(\"^[+-]?\\\\d{1,19}$\");\n}","tryCatchPattern":"try {\n    return longCodec.parse(raw);\n} catch (InvalidTypeException e) {\n    throw new IllegalArgumentException(\"Not a 64-bit integer literal: \" + raw, e);\n}","preventionTips":["Pre-parse with Long.parseLong in a guarded helper so failures surface before codec calls.","Check the value fits in [-9223372036854775808, 9223372036854775807] when importing from other systems.","Strip whitespace and grouping separators before parsing CSV/config numbers."],"tags":["cql","bigint","codec","number-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}