apache/cassandra · error · MarshalException
Unable to make double from '%s'
Error message
Unable to make double from '%s'
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/DoubleType.java:92
@Override
public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
{
return ByteSourceInverse.getOptionalSignedFixedLengthFloat(accessor, comparableBytes, 8);
}
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(Double.valueOf(source));
}
catch (NumberFormatException e1)
{
throw new MarshalException(String.format("Unable to make double 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).doubleValue()));
}
catch (ClassCastException exc)
{
throw new MarshalException(String.format(
"Expected a double value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
}View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before
DoubleType.instance.fromString("1,234.5"); // MarshalException
// after
DoubleType.instance.fromString("1234.5"); Defensive patterns
Strategy: validation
Validate before calling
boolean isValidDoubleLiteral(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; } } Try / catch
try { DoubleType.instance.fromString(source); } catch (MarshalException e) { log.warn("Invalid double literal: {}", source); } Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
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 float 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/2f6545a4fb936dac.
Report an issue: GitHub.