apache/cassandra · error · MarshalException
Unable to make float from '%s'
Error message
Unable to make float from '%s'
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/FloatType.java:93
@Override
public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
{
return ByteSourceInverse.getOptionalSignedFixedLengthFloat(accessor, comparableBytes, 4);
}
public ByteBuffer fromString(String source) throws MarshalException
{
// Return an empty ByteBuffer for an empty string.
if (source.isEmpty())
return ByteBufferUtil.EMPTY_BYTE_BUFFER;
try
{
return decompose(Float.parseFloat(source));
}
catch (NumberFormatException e1)
{
throw new MarshalException(String.format("Unable to make float from '%s'", source), e1);
}
}
@Override
public Term fromJSONObject(Object parsed) throws MarshalException
{
try
{
if (parsed instanceof String)
return new Constants.Value(fromString((String) parsed));
else
return new Constants.Value(getSerializer().serialize(((Number) parsed).floatValue()));
}
catch (ClassCastException exc)
{
throw new MarshalException(String.format(
"Expected a float value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
}View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before
FloatType.instance.fromString("3,14");
// after
FloatType.instance.fromString("3.14"); Defensive patterns
Strategy: validation
Validate before calling
boolean isValidFloatLiteral(String s) { try { Float.parseFloat(s); return true; } catch (NumberFormatException e) { return false; } } Try / catch
try { FloatType.instance.fromString(source); } catch (MarshalException e) { log.warn("Invalid float literal: {}", source); } Prevention
- Pre-validate float literals with Float.parseFloat
- Normalize locale decimal separators before binding
- Prefer typed bind variables over string literals for float columns
When it happens
Trigger: 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.
Common situations: Locale-formatted decimal strings with commas; truncated numerics from log parsing; free-text accidentally bound to a float column.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Unable to make double from '%s'
- In call to function %s, value 0x%s is not a valid binary rep
- ' is not empty
- Expected a float value, but got a %s: %s
- Unable to make inet address from '%s'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/9cfc3143999e6606.
Report an issue: GitHub.