apache/cassandra · error · InvalidRequestException
e.getMessage()
Error message
e.getMessage()
What it means
Wraps a MarshalException raised when the type's fromString() parser rejects the literal text during parsedValue(). The message is the marshal error text, e.g. 'Unable to make int from "abc"'. It means the constant's format is not valid for the target type.
Source
Thrown at src/java/org/apache/cassandra/cql3/terms/Constants.java:320
private ByteBuffer parsedValue(AbstractType<?> validator) throws InvalidRequestException
{
if (validator instanceof ReversedType<?>)
validator = ((ReversedType<?>) validator).baseType;
try
{
if (type == Type.HEX)
// Note that validator could be BytesType, but it could also be a custom type, so
// we hardcode BytesType (rather than using 'validator') in the call below.
// Further note that BytesType doesn't want it's input prefixed by '0x', hence the substring.
return BytesType.instance.fromString(text.substring(2));
if (validator instanceof CounterColumnType)
return LongType.instance.fromString(text);
return validator.fromString(text);
}
catch (MarshalException e)
{
throw new InvalidRequestException(e.getMessage());
}
}
@Override
public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
CQL3Type receiverType = receiver.type.asCQL3Type();
if (receiverType.isCollection() || receiverType.isUDT() || receiverType.isVector())
return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
if (!(receiverType instanceof CQL3Type.Native))
// Skip type validation for custom types. May or may not be a good idea
return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;
CQL3Type.Native nt = (CQL3Type.Native)receiverType;
// If the receiver type match the prefered type we can straight away return an exact match
if (nt.getType().equals(preferedType))View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Fix the literal to the canonical CQL format for the column type (int: digits; uuid: 8-4-4-4-12 hex; blob: 0x hex; timestamp: ISO-8601)
- Use bound parameters and let the driver serialize typed values instead of string literals
- Read the embedded marshal message to see which type and text failed
Example fix
// before INSERT INTO t (k, ts) VALUES (0, '01/02/2024'); // unsupported format // after INSERT INTO t (k, ts) VALUES (0, '2024-01-02T00:00:00+0000');
Defensive patterns
Strategy: validation
Validate before calling
try { targetCqlTypeFromString(text); } catch (Exception e) { throw new IllegalArgumentException("bad literal: " + text); } Try / catch
try { session.execute(query); } catch (InvalidQueryException e) { /* message carries the MarshalException text; log text + expected type */ } Prevention
- Use canonical CQL literal formats (ISO-8601 timestamps, unquoted uuids, 0x blobs)
- Prefer bound parameters over string literals
- Avoid locale-formatted numbers/dates in CQL text
When it happens
Trigger: `INSERT ... VALUES (0, 'not-a-number')` for an int column; malformed uuid, date, inet, or blob (non-hex) literals reaching type.fromString().
Common situations: Typos in numeric/UUID/date literals; locale-formatted numbers ('1,000'); users pasting formatted dates unsupported by CQL (must be ISO-8601 or epoch millis); blobs given without 0x prefix.
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
- Unknown duration symbol '%s'
- (dynamic MarshalException message)
- Failed parsing statement: [%s] reason: %s %s
- Cannot parse constraint value from <term> for column '<colum
- Invalid table id
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/973071b7c713a2a2.
Report an issue: GitHub.