{"record":{"id":"08a1cf6581b6df35","repo":"apache/cassandra","slug":"text-does-not-match-time","errorCode":null,"errorMessage":"{text} does not match {TIME}","messagePattern":"(.+?) does not match (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/TimeoutStrategy.java","lineNumber":392,"sourceCode":"            return new Wait.Constant(((Constant) supplier).micros);\n        if (modifier == null)\n            modifier = modifiers.identity();\n        return new Wait.Modifying(supplier, modifier);\n    }\n\n    public static long parseInMicros(String input, long orElse)\n    {\n        if (input == null)\n            return orElse;\n\n        return parseInMicros(input);\n    }\n\n    public static long parseInMicros(String text)\n    {\n        Matcher m = TIME.matcher(text);\n        if (!m.matches())\n            throw new IllegalArgumentException(text + \" does not match \" + TIME);\n\n        if (text.length() == 1)\n        {\n            Invariants.require(text.charAt(0) == '0');\n            return 0;\n        }\n\n        char penultimate = text.charAt(text.length() - 2);\n        switch (penultimate)\n        {\n            default:  return parseInt(text.substring(0, text.length() - 1)) * 1000_000L;\n            case 'm': return parseInt(text.substring(0, text.length() - 2)) * 1000L;\n            case 'u': return parseInt(text.substring(0, text.length() - 2));\n        }\n    }\n\n    private static String orElse(Supplier<String> get, String orElse)\n    {","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/TimeoutStrategy.java#L374-L410","documentation":"Thrown by TimeoutStrategy.parseInMicros when the text does not match the TIME regex, which recognizes duration values with time units (us/ms/s/m/h/d etc.). The message shows the offending text and the expected pattern.","triggerScenarios":"Calling parseInMicros (directly or via parse/parseWait/modifier) with a string that is not '<number><unit>', e.g. '100' with no unit, 'ms100', or a misspelled unit.","commonSituations":"Omitting the time unit ('100' instead of '100ms'); unsupported units like 'sec' or 'minutes'; extra whitespace or invisible characters in config values.","solutions":["Append a recognized time unit: us, ms, s, m, h, or d (e.g. '100ms').","Check for and remove stray whitespace or typo'd units.","Use the pattern in the message to confirm which units the TIME regex accepts."],"exampleFix":"// before\nlong micros = TimeoutStrategy.parseInMicros(\"100\"); // missing unit\n// after\nlong micros = TimeoutStrategy.parseInMicros(\"100ms\");","handlingStrategy":"validation","validationCode":"if (text == null || !text.matches(\"[0-9]+(?:\\\\.[0-9]+)?(?:us|ms|s|m|h|d)\")) throw new IllegalArgumentException(\"duration must be <number><unit>, got: \" + text);","typeGuard":null,"tryCatchPattern":"try { long micros = TimeoutStrategy.parseInMicros(text); }\ncatch (IllegalArgumentException e) { if (e.getMessage().contains(\"does not match\")) { /* append a valid unit */ } throw e; }","preventionTips":["Always include a time unit ('100ms', not '100')","Use only supported units (us, ms, s, m, h, d)","Trim whitespace from config values before parsing"],"tags":["cassandra","configuration","timeout","duration-format","parse-error"],"backgroundTag":"invalid-duration-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}