{"record":{"id":"9cfc3143999e6606","repo":"apache/cassandra","slug":"unable-to-make-float-from-s","errorCode":null,"errorMessage":"Unable to make float from '%s'","messagePattern":"Unable to make float from '(.+?)'","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/FloatType.java","lineNumber":93,"sourceCode":"    @Override\n    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)\n    {\n        return ByteSourceInverse.getOptionalSignedFixedLengthFloat(accessor, comparableBytes, 4);\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(Float.parseFloat(source));\n      }\n      catch (NumberFormatException e1)\n      {\n          throw new MarshalException(String.format(\"Unable to make float 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).floatValue()));\n        }\n        catch (ClassCastException exc)\n        {\n            throw new MarshalException(String.format(\n                    \"Expected a float value, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n        }","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/FloatType.java#L75-L111","documentation":"FloatType.fromString() parses a CQL string into a float via Float.parseFloat(). When the string is not a valid Java float literal, NumberFormatException is caught and rethrown as a MarshalException with the original text embedded. This protects float column deserialization from malformed literal values.","triggerScenarios":"Calling FloatType.instance.fromString(...) (directly or via fromJSONObject with a string value) with non-parseable text like '3,14', '1.2.3', 'abc', or an empty string.","commonSituations":"Locale-formatted decimal strings with commas; truncated numerics from log parsing; free-text accidentally bound to a float column.","solutions":["Correct the input to a valid float literal (e.g. '3.14', '-1e3', 'NaN')","Normalize locale formatting (replace ',' decimal separator, strip grouping) before parsing","Send JSON numbers instead of strings so fromJSONObject uses the Number branch","Pre-validate with Float.parseFloat in a try/catch before submitting"],"exampleFix":"// before\nFloatType.instance.fromString(\"3,14\");\n// after\nFloatType.instance.fromString(\"3.14\");","handlingStrategy":"validation","validationCode":"boolean isValidFloatLiteral(String s) { try { Float.parseFloat(s); return true; } catch (NumberFormatException e) { return false; } }","typeGuard":null,"tryCatchPattern":"try { FloatType.instance.fromString(source); } catch (MarshalException e) { log.warn(\"Invalid float literal: {}\", source); }","preventionTips":["Pre-validate float literals with Float.parseFloat","Normalize locale decimal separators before binding","Prefer typed bind variables over string literals for float columns"],"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"}