{"record":{"id":"ed239977eeb5ff33","repo":"apache/cassandra","slug":"second-out-of-bounds","errorCode":null,"errorMessage":"Second out of bounds.","messagePattern":"Second out of bounds\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/ParseUtils.java","lineNumber":419,"sourceCode":"\n        // Parse the time\n        int firstColon = str.indexOf(':');\n        int secondColon = str.indexOf(':', firstColon + 1);\n\n        // Convert the time; default missing nanos\n        if (firstColon > 0 && secondColon > 0 && secondColon < str.length() - 1)\n        {\n            int period = str.indexOf('.', secondColon + 1);\n            hour = Integer.parseInt(str.substring(0, firstColon));\n            if (hour < 0 || hour >= 24) throw new IllegalArgumentException(\"Hour out of bounds.\");\n\n            minute = Integer.parseInt(str.substring(firstColon + 1, secondColon));\n            if (minute < 0 || minute >= 60) throw new IllegalArgumentException(\"Minute out of bounds.\");\n\n            if (period > 0 && period < str.length() - 1)\n            {\n                second = Integer.parseInt(str.substring(secondColon + 1, period));\n                if (second < 0 || second >= 60) throw new IllegalArgumentException(\"Second out of bounds.\");\n\n                nanos_s = str.substring(period + 1);\n                if (nanos_s.length() > 9) throw new IllegalArgumentException(formatError);\n                if (!Character.isDigit(nanos_s.charAt(0))) throw new IllegalArgumentException(formatError);\n                nanos_s = nanos_s + zeros.substring(0, 9 - nanos_s.length());\n                a_nanos = Integer.parseInt(nanos_s);\n            }\n            else if (period > 0) throw new ParseException(formatError, -1);\n            else\n            {\n                second = Integer.parseInt(str.substring(secondColon + 1));\n                if (second < 0 || second >= 60) throw new ParseException(\"Second out of bounds.\", -1);\n            }\n        }\n        else throw new ParseException(formatError, -1);\n\n        long rawTime = 0;\n        rawTime += TimeUnit.HOURS.toNanos(hour);","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/ParseUtils.java#L401-L437","documentation":"parseTime validated the seconds component of the time string and found it outside the valid range 0-59. As with hour and minute, CQL `time` requires a real time-of-day value; seconds of 60+ (or negative) raise this IllegalArgumentException. (Leap-second 60 is not accepted.)","triggerScenarios":"Calling ParseUtils.parseTime(\"12:30:60\"), \"23:59:60\" (leap second), or any string whose seconds substring (between the second colon and the period) parses to an int outside [0, 59].","commonSituations":"Leap-second timestamps from NTP/GPS or astronomical data, rounded cumulative second counts, or data exported from systems that allow 60 for leap seconds.","solutions":["Convert leap seconds: map :60 to the next second (23:59:60 -> next day 00:00:00) or clamp to :59 before parsing.","Validate seconds between 0 and 59 before calling parseTime.","Use java.time.Instant/Duration handling for leap-second-aware sources instead of the `time` type.","Catch IllegalArgumentException and report the offending component."],"exampleFix":"// before\nlong nanos = ParseUtils.parseTime(\"23:59:60\"); // throws\n// after\nString s = \"23:59:60\";\nif (s.endsWith(\":60\")) s = s.substring(0, 6) + \":59\"; // or roll to next day\nlong nanos = ParseUtils.parseTime(s);","handlingStrategy":"validation","validationCode":"int sec = Integer.parseInt(s.substring(s.indexOf(':', s.indexOf(':') + 1) + 1).split(\"\\\\.\")[0]);\nif (sec < 0 || sec > 59) throw new IllegalArgumentException(\"second must be 0-59: \" + sec);","typeGuard":null,"tryCatchPattern":"try { return ParseUtils.parseTime(s); }\ncatch (IllegalArgumentException e) { throw new IllegalArgumentException(\"Invalid seconds in '\" + s + \"'\", e); }","preventionTips":["Convert leap-second (:60) values before parsing","Clamp or roll seconds >= 60 at the data-ingestion boundary","Remember CQL time does not support leap seconds"],"tags":["parsing","time","range-check","illegal-argument"],"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"}