{"record":{"id":"978dfdb711393020","repo":"apache/cassandra","slug":"cannot-parse-64-bits-double-value-from-s","errorCode":null,"errorMessage":"Cannot parse 64-bits double value from \"%s\"","messagePattern":"Cannot parse 64-bits double value from \"(.+?)\"","errorType":"validation","errorClass":"InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java","lineNumber":1385,"sourceCode":"\n        @Override\n        public int serializedSize()\n        {\n            return 8;\n        }\n\n        @Override\n        public Double parse(String value)\n        {\n            try\n            {\n                return value == null || value.isEmpty() || value.equalsIgnoreCase(\"NULL\")\n                       ? null\n                       : Double.parseDouble(value);\n            }\n            catch (NumberFormatException e)\n            {\n                throw new InvalidTypeException(\n                String.format(\"Cannot parse 64-bits double value from \\\"%s\\\"\", value));\n            }\n        }\n\n        @Override\n        public String format(Double value)\n        {\n            if (value == null) return \"NULL\";\n            return Double.toString(value);\n        }\n\n        @Override\n        public ByteBuffer serializeNoBoxing(double value, ProtocolVersion protocolVersion)\n        {\n            ByteBuffer bb = ByteBuffer.allocate(8);\n            bb.putDouble(0, value);\n            return bb;\n        }","sourceCodeStart":1367,"sourceCodeEnd":1403,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L1367-L1403","documentation":"The double codec's parse() delegates to Double.parseDouble; strings that are not valid Java/CQL double literals (NaN and Infinity accepted by Java) raise NumberFormatException, rethrown as InvalidTypeException with this message. It covers 64-bit IEEE-754 'double' column values only.","triggerScenarios":"Calling doubleCodec.parse(value) with strings like \"1,5\", \"1.2.3\", \"1.5f\" (trailing type suffix), \"1e\" (incomplete exponent), currency-formatted values, or arbitrary text.","commonSituations":"Locale-formatted numbers using comma as decimal separator; float literals copied from Java/C# source carrying an f/F suffix; truncated exponent notation; CSV cells containing text in a numeric column.","solutions":["Normalize the string: replace decimal comma with dot, trim whitespace, strip trailing f/F/d/D suffixes.","Use a Locale-aware NumberFormat for localized input and pass format.parse(s).doubleValue() results via codec.format instead.","Validate with a regex like ^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][+-]?\\d+)?$ before parsing."],"exampleFix":"// before\ndoubleCodec.parse(\"1,5\"); // throws (NumberFormatException)\n// after\ndoubleCodec.parse(\"1,5\".replace(',', '.')); // parses 1.5","handlingStrategy":"validation","validationCode":"static boolean isCqlDoubleLiteral(String v) {\n    return v != null && v.trim().matches(\"^[+-]?(\\\\d+(\\\\.\\\\d*)?|\\\\.\\\\d+)([eE][+-]?\\\\d+)?$|^NaN$|^[+-]?Infinity$\");\n}","typeGuard":"boolean isDoubleLiteral(String v) {\n    if (v == null) return false;\n    try { Double.parseDouble(v.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    return doubleCodec.parse(raw);\n} catch (InvalidTypeException e) {\n    throw new IllegalArgumentException(\"Not a valid double literal: \" + raw, e);\n}","preventionTips":["Replace locale decimal commas with dots and strip trailing f/d suffixes before parsing.","Use NumberFormat with the correct Locale when input is user/localized, then pass double values via codec.format().","Pre-validate with Double.parseDouble in a guarded helper before invoking the codec."],"tags":["cql","double","codec","number-parsing","locale"],"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"}