apache/cassandra · error · MarshalException

Input date %s is less than min supported date %s

Error message

Input date %s is less than min supported date %s

What it means

SimpleDateSerializer.dateStringToDays parses a textual date and converts it to Cassandra's date encoding (milliseconds since epoch offset). Dates earlier than the minimum supported date (the type's epoch-based range, roughly year -5877649 onward) are rejected with this MarshalException naming both the input and the minimum.

Source

Thrown at src/java/org/apache/cassandra/serializers/SimpleDateSerializer.java:74

    {
        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);
    }

    public static int dateStringToDays(String source) throws MarshalException
    {
        // Raw day value in unsigned int form, epoch @ 2^31
        if (rawPattern.matcher(source).matches())
        {
            return parseRaw(source);
        }

        // Attempt to parse as date string
        try
        {
            LocalDate parsed = formatter.parse(source, LocalDate::from);
            long millis = parsed.atStartOfDay(UTC).toInstant().toEpochMilli();
            if (millis < minSupportedDateMillis)
                throw new MarshalException(String.format("Input date %s is less than min supported date %s", source,
                        ZonedDateTime.ofInstant(Instant.ofEpochMilli(minSupportedDateMillis), UTC).toString()));
            if (millis > maxSupportedDateMillis)
                throw new MarshalException(String.format("Input date %s is greater than max supported date %s", source,
                        ZonedDateTime.ofInstant(Instant.ofEpochMilli(maxSupportedDateMillis), UTC).toString()));

            return timeInMillisToDay(millis);
        }
        catch (DateTimeParseException| ArithmeticException e1)
        {
            throw new MarshalException(String.format("Unable to coerce '%s' to a formatted date (long)", source), e1);
        }
    }

    private static int parseRaw(String source) {
        try
        {
            long result = Long.parseLong(source);

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use values within the supported range; for dates below the minimum, store a text column instead.
  2. If you need the raw days-since-epoch encoding, pass an unsigned integer (e.g. as string form of the encoded value) rather than a calendar date string.
  3. Clamp or validate user input dates against the supported minimum before binding.
  4. Check the error's min date string in the message and adjust the input accordingly.

Example fix

// before
stmt.bind("1970-01-01"); // fine, but extreme dates below min are not
LocalDate d = LocalDate.of(-6000000, 1, 1); // below supported range
stmt.setLocalDate("d", d);
// after
if (d.toEpochDay() * 86400000L < minSupportedDateMillis) {
    throw new IllegalArgumentException("date below Cassandra date range");
}
stmt.setLocalDate("d", d);
Defensive patterns

Strategy: validation

Validate before calling

// Java
long millis = date.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli();
if (millis < minSupportedDateMillis || millis > maxSupportedDateMillis) {
    throw new IllegalArgumentException("date outside Cassandra date range");
}

Try / catch

try {
    int encoded = SimpleDateSerializer.instance.dateStringToDays(input);
} catch (MarshalException e) {
    log.warn("Unsupported date {}: {}", input, e.getMessage());
}

Prevention

When it happens

Trigger: INSERT/bind with a date string like '0001-01-01' as a plain calendar date for a date column in a context where it falls below minSupportedDateMillis per the configured range; passing extreme negative dates via cqlsh or a driver string binding.

Common situations: Historical/archaeological dates outside Cassandra's date type range; users confusing the date type's unsigned-integer encoding with a plain calendar range; naive form inputs allowing any year.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ddb409659591bec5. Report an issue: GitHub.