apache/cassandra · error · IllegalArgumentException

does not match

Error message

{input} does not match {WAIT}

What it means

Thrown by TimeoutStrategy.parseWait when the wait-expression portion of a timeout spec fails to match the WAIT regex. The WAIT grammar accepts constant durations or latency-source expressions with optional modifiers.

Solutions

  1. Check the input against the WAIT pattern included in the message.
  2. Use a plain duration (e.g. '500ms') or a valid latency source name registered with the LatencySourceFactory.
  3. Validate the modifier syntax attached to the wait expression ('*' or '^' followed by a number).

Example fix

// before
Wait w = TimeoutStrategy.parseWait("latency*xyz", latencies); // no such latency source/modifier
// after
Wait w = TimeoutStrategy.parseWait("latency*2", latencies);
Defensive patterns

Strategy: validation

Validate before calling

// Wait clause must be a duration or registered latency source (+ optional *N or ^N)
if (!input.matches("(?:<duration>|(?:<latencySource>)(?:[*^][0-9.]+)?)")) throw new IllegalArgumentException("invalid wait: " + input);

Try / catch

try { TimeoutStrategy.parseWait(input, latencies); }
catch (IllegalArgumentException e) { if (e.getMessage().contains("does not match")) { /* correct wait expression */ } throw e; }

Prevention

When it happens

Trigger: A wait clause inside a timeout strategy string that is neither a recognized constant duration nor a valid latency-source expression, e.g. 'latency*foo' or gibberish text.

Common situations: Referencing a latency source name that does not exist; malformed modifier attached to the wait; typos in documented spec strings.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/service/TimeoutStrategy.java:362

        if (!m.matches())
            throw new IllegalArgumentException("Invalid specification: '" + input + "'; does not match " + PARSE);
        long min = parseInMicros(m.group("min"), 0);
        long max = parseInMicros(m.group("max"), Long.MAX_VALUE);
        Wait wait = TimeoutStrategy.parseWait(m.group("wait"), latencies);
        return new TimeoutStrategy(wait, min, max);
    }

    public static Wait parseWait(String input, LatencySourceFactory latencies)
    {
        return parseWait(input, latencies, modifiers);
    }

    @VisibleForTesting
    static Wait parseWait(String input, LatencySourceFactory latencies, LatencyModifierFactory modifiers)
    {
        Matcher m = WAIT.matcher(input);
        if (!m.matches())
            throw new IllegalArgumentException(input + " does not match " + WAIT);

        String maybeConst = m.group("const");
        if (maybeConst != null)
        {
            long v = parseInMicros(maybeConst);
            return new Wait.Constant(v);
        }

        LatencySupplier supplier = parseLatencySupplier(m, latencies);
        LatencyModifier modifier = parseLatencyModifier(input, m, modifiers);
        if (modifier == null && supplier instanceof LatencySupplier.Constant)
            return new Wait.Constant(((Constant) supplier).micros);
        if (modifier == null)
            modifier = modifiers.identity();
        return new Wait.Modifying(supplier, modifier);
    }

    public static long parseInMicros(String input, long orElse)

View on GitHub (pinned to 88fd0f6a0e)