{"record":{"id":"2f6545a4fb936dac","repo":"apache/cassandra","slug":"unable-to-make-double-from-s","errorCode":null,"errorMessage":"Unable to make double from '%s'","messagePattern":"Unable to make double from '(.+?)'","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/DoubleType.java","lineNumber":92,"sourceCode":"    @Override\n    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)\n    {\n        return ByteSourceInverse.getOptionalSignedFixedLengthFloat(accessor, comparableBytes, 8);\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n      // Return an empty ByteBuffer for an empty string.\n      if (source.isEmpty())\n          return ByteBufferUtil.EMPTY_BYTE_BUFFER;\n\n      try\n      {\n          return decompose(Double.valueOf(source));\n      }\n      catch (NumberFormatException e1)\n      {\n          throw new MarshalException(String.format(\"Unable to make double from '%s'\", source), e1);\n      }\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        try\n        {\n            if (parsed instanceof String)\n                return new Constants.Value(fromString((String) parsed));\n            else\n                return new Constants.Value(getSerializer().serialize(((Number) parsed).doubleValue()));\n        }\n        catch (ClassCastException exc)\n        {\n            throw new MarshalException(String.format(\n                    \"Expected a double value, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n        }","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/DoubleType.java#L74-L110","documentation":"DoubleType.fromString() parses a CQL string into a double by delegating to Double.valueOf(). When the string is not a valid Java double literal, NumberFormatException is caught and rethrown as a MarshalException with the offending source text embedded. This guards the deserialization path from user-supplied literal values in CQL, JSON, and SSTable-attached strings.","triggerScenarios":"Calling DoubleType.instance.fromString(...) (directly or via fromJSONObject on a JSON string value) with text that Double.valueOf cannot parse, e.g. '12.3.4', 'abc', or a locale-formatted number like '1,23'.","commonSituations":"Application code sends numeric literals in a locale format with comma decimal separators; a JSON string column value contains non-numeric text; scripts generate literals with typo'd or empty strings for double columns.","solutions":["Fix the input string to be a valid double literal parseable by Double.valueOf (e.g. '1.5', '-0.3e10', 'NaN')","Strip locale-specific formatting (thousands separators, comma decimal points) before passing the string","If the value comes from JSON, ensure numbers are passed as JSON numbers so fromJSONObject uses the Number branch instead of string parsing","Validate the literal client-side with Double.parseDouble in a try/catch before submitting"],"exampleFix":"// before\nDoubleType.instance.fromString(\"1,234.5\"); // MarshalException\n// after\nDoubleType.instance.fromString(\"1234.5\");","handlingStrategy":"validation","validationCode":"boolean isValidDoubleLiteral(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; } }","typeGuard":null,"tryCatchPattern":"try { DoubleType.instance.fromString(source); } catch (MarshalException e) { log.warn(\"Invalid double literal: {}\", source); }","preventionTips":["Validate numeric literals with Double.parseDouble before binding","Never pass locale-formatted numbers to Cassandra string parsing","Prefer typed bindings (PreparedStatement with double parameters) over string literals"],"tags":["cassandra","marshalling","type-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-14T21:17:11.552Z"}