{"record":{"id":"ddb409659591bec5","repo":"apache/cassandra","slug":"input-date-s-is-less-than-min-supported-date-s","errorCode":null,"errorMessage":"Input date %s is less than min supported date %s","messagePattern":"Input date (.+?) is less than min supported date (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/serializers/SimpleDateSerializer.java","lineNumber":74,"sourceCode":"    {\n        return value == null ? ByteBufferUtil.EMPTY_BYTE_BUFFER : ByteBufferUtil.bytes(value);\n    }\n\n    public static int dateStringToDays(String source) throws MarshalException\n    {\n        // Raw day value in unsigned int form, epoch @ 2^31\n        if (rawPattern.matcher(source).matches())\n        {\n            return parseRaw(source);\n        }\n\n        // Attempt to parse as date string\n        try\n        {\n            LocalDate parsed = formatter.parse(source, LocalDate::from);\n            long millis = parsed.atStartOfDay(UTC).toInstant().toEpochMilli();\n            if (millis < minSupportedDateMillis)\n                throw new MarshalException(String.format(\"Input date %s is less than min supported date %s\", source,\n                        ZonedDateTime.ofInstant(Instant.ofEpochMilli(minSupportedDateMillis), UTC).toString()));\n            if (millis > maxSupportedDateMillis)\n                throw new MarshalException(String.format(\"Input date %s is greater than max supported date %s\", source,\n                        ZonedDateTime.ofInstant(Instant.ofEpochMilli(maxSupportedDateMillis), UTC).toString()));\n\n            return timeInMillisToDay(millis);\n        }\n        catch (DateTimeParseException| ArithmeticException e1)\n        {\n            throw new MarshalException(String.format(\"Unable to coerce '%s' to a formatted date (long)\", source), e1);\n        }\n    }\n\n    private static int parseRaw(String source) {\n        try\n        {\n            long result = Long.parseLong(source);\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/serializers/SimpleDateSerializer.java#L56-L92","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use values within the supported range; for dates below the minimum, store a text column instead.","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.","Clamp or validate user input dates against the supported minimum before binding.","Check the error's min date string in the message and adjust the input accordingly."],"exampleFix":"// before\nstmt.bind(\"1970-01-01\"); // fine, but extreme dates below min are not\nLocalDate d = LocalDate.of(-6000000, 1, 1); // below supported range\nstmt.setLocalDate(\"d\", d);\n// after\nif (d.toEpochDay() * 86400000L < minSupportedDateMillis) {\n    throw new IllegalArgumentException(\"date below Cassandra date range\");\n}\nstmt.setLocalDate(\"d\", d);","handlingStrategy":"validation","validationCode":"// Java\nlong millis = date.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli();\nif (millis < minSupportedDateMillis || millis > maxSupportedDateMillis) {\n    throw new IllegalArgumentException(\"date outside Cassandra date range\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    int encoded = SimpleDateSerializer.instance.dateStringToDays(input);\n} catch (MarshalException e) {\n    log.warn(\"Unsupported date {}: {}\", input, e.getMessage());\n}","preventionTips":["Range-check user-supplied dates before binding to date columns","Use the plain date format YYYY-MM-DD within the supported range","Store out-of-range dates in text columns instead","Read the min/max dates from the exception message for exact bounds"],"tags":["cassandra","serialization","date","range"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}