apache/cassandra · error · MarshalException
Invalid Timestamp:
Error message
Invalid Timestamp:
What it means
TimestampUtf8Type stores timestamps as UTF-8 strings and its validator re-checks every value: the string must be non-empty and parseable by Timestamp.tryParse. Values that parse as UTF-8 but not as a timestamp fail with this MarshalException, so it is stricter than plain utf8 validation.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/TimestampUtf8Type.java:41
import org.apache.cassandra.cql3.functions.ArgumentDeserializer;
import org.apache.cassandra.serializers.MarshalException;
import org.apache.cassandra.serializers.TypeSerializer;
import org.apache.cassandra.serializers.UTF8Serializer;
import org.apache.cassandra.utils.ByteBufferUtil;
public class TimestampUtf8Type extends PseudoUtf8Type
{
public static final TimestampUtf8Type instance = new TimestampUtf8Type();
static final TypeSerializer<String> timestampSerializer = new UTF8Serializer()
{
@Override
public <V> void validate(V value, ValueAccessor<V> accessor) throws MarshalException
{
super.validate(value, accessor);
String str = deserialize(value, accessor);
if (!str.isEmpty() && null == Timestamp.tryParse(str))
throw new MarshalException("Invalid Timestamp: " + str);
}
};
private static final ArgumentDeserializer ARGUMENT_DESERIALIZER = new DefaultArgumentDeserializer(instance);
private static final ByteBuffer MASKED_VALUE = ByteBufferUtil.EMPTY_BYTE_BUFFER;
TimestampUtf8Type() {} // singleton
String describe() { return "TxnId"; }
@Override
public TypeSerializer<String> getSerializer()
{
return timestampSerializer;
}
@Override
public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pre-validate on the client with Timestamp.tryParse (or java.time parsing) before binding.
- Send dates in Cassandra's expected format (yyyy-MM-dd HH:mm:ss[.SSS] or ISO variants).
- Use TimestampType (binary) instead of TimestampUtf8Type if you don't need string storage.
Example fix
// before
String val = userSuppliedDate; // "09/09/2026"
// after
if (com.datastax.driver.core.LocalDate.class != null && !isParseableTimestamp(userSuppliedDate))
throw new IllegalArgumentException("invalid timestamp: " + userSuppliedDate); Defensive patterns
Strategy: validation
Validate before calling
if (str != null && !str.isEmpty() && com.datastax... ) boolean valid = Timestamp.tryParse(str) != null; // or try java.time parse with expected formats
Try / catch
try { type.validate(bb, ByteBufferAccessor.instance); } catch (MarshalException e) { /* reject input: e.getMessage() */ } Prevention
- Pre-parse timestamps with java.time using the exact formats Cassandra accepts
- Use TimestampType instead of the UTF8 variant when string storage is not required
- Reject free-text input for timestamp columns at the UI layer
When it happens
Trigger: Inserting/updating a column (e.g. a SASI/indexable timestamp-as-string column) with text like 'not-a-date', '2026-13-45', or an empty check that fails Timestamp.tryParse; UDF/secondary-index validation paths invoking validate().
Common situations: Free-text input bound to a timestamp-as-string column; locale-specific date formats that Cassandra's parser does not accept; truncated date strings from string-slicing code.
Related errors
- REVOKE operation is not supported by AllowAllAuthorizer
- %s is not a valid data resource name
- %s is not a valid function resource name
- Invalid value of auto_snapshot_ttl: ${conf.auto_snapshot_ttl
- Invalid value %d for %s: negative values are not allowed, ou
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/89f67feaf5106bc4.
Report an issue: GitHub.