apache/cassandra · error · IllegalArgumentException

Minute out of bounds.

Error message

Minute out of bounds.

What it means

parseTime validated the minute component of the time string and found it outside the valid range 0-59. CQL `time` values must be a real time of day, so minutes of 60+ (or negative) are rejected with this IllegalArgumentException.

Source

Thrown at src/java/org/apache/cassandra/cql3/functions/types/ParseUtils.java:414

        String formatError = "Timestamp format must be hh:mm:ss[.fffffffff]";
        String zeros = "000000000";

        if (str == null) throw new IllegalArgumentException(formatError);
        str = str.trim();

        // Parse the time
        int firstColon = str.indexOf(':');
        int secondColon = str.indexOf(':', firstColon + 1);

        // Convert the time; default missing nanos
        if (firstColon > 0 && secondColon > 0 && secondColon < str.length() - 1)
        {
            int period = str.indexOf('.', secondColon + 1);
            hour = Integer.parseInt(str.substring(0, firstColon));
            if (hour < 0 || hour >= 24) throw new IllegalArgumentException("Hour out of bounds.");

            minute = Integer.parseInt(str.substring(firstColon + 1, secondColon));
            if (minute < 0 || minute >= 60) throw new IllegalArgumentException("Minute out of bounds.");

            if (period > 0 && period < str.length() - 1)
            {
                second = Integer.parseInt(str.substring(secondColon + 1, period));
                if (second < 0 || second >= 60) throw new IllegalArgumentException("Second out of bounds.");

                nanos_s = str.substring(period + 1);
                if (nanos_s.length() > 9) throw new IllegalArgumentException(formatError);
                if (!Character.isDigit(nanos_s.charAt(0))) throw new IllegalArgumentException(formatError);
                nanos_s = nanos_s + zeros.substring(0, 9 - nanos_s.length());
                a_nanos = Integer.parseInt(nanos_s);
            }
            else if (period > 0) throw new ParseException(formatError, -1);
            else
            {
                second = Integer.parseInt(str.substring(secondColon + 1));
                if (second < 0 || second >= 60) throw new ParseException("Second out of bounds.", -1);
            }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Normalize by carrying overflow: 01:90:00 -> 02:30:00 before parsing.
  2. Validate minutes between 0 and 59 before calling parseTime.
  3. If the value is a duration, use a duration representation instead of `time`.
  4. Catch IllegalArgumentException and re-prompt or report the invalid component.

Example fix

// before
long nanos = ParseUtils.parseTime("01:90:00"); // throws
// after
int minutes = 90, hours = 1;
hours += minutes / 60; minutes %= 60;
long nanos = ParseUtils.parseTime(String.format("%02d:%02d:00", hours, minutes));
Defensive patterns

Strategy: validation

Validate before calling

int m = Integer.parseInt(s.substring(s.indexOf(':') + 1, s.indexOf(':', s.indexOf(':') + 1)));
if (m < 0 || m > 59) throw new IllegalArgumentException("minute must be 0-59: " + m);

Try / catch

try { return ParseUtils.parseTime(s); }
catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid minutes in '" + s + "'", e); }

Prevention

When it happens

Trigger: Calling ParseUtils.parseTime("12:60:00"), "10:75:30", or any string whose substring between the first and second colon parses to an int outside [0, 59].

Common situations: Accumulated/rounded minute values (e.g. 90 minutes represented as "01:90:00" instead of "01:30:00"), spreadsheet or user data with minutes >= 60, or locale-formatted times that were partially normalized.

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/f4c8528f9c092df3. Report an issue: GitHub.