{"record":{"id":"650ab6aa6d00ea13","repo":"apache/cassandra","slug":"invalid-latency-modifier-specification-spec-ex","errorCode":null,"errorMessage":"Invalid latency modifier specification: {spec}. Expect constant factor as base for exponent.","messagePattern":"Invalid latency modifier specification: (.+?)\\. Expect constant factor as base for exponent\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/TimeoutStrategy.java","lineNumber":321,"sourceCode":"        if (perc == null)\n            return new Constant(parseInMicros(m.group(\"constbase\")));\n\n        String rw = m.group(\"rw\");\n        if (rw == null) rw = \"rw\";\n        LatencySource latencies = latenciesFactory.source(rw);\n        double percentile = parseDouble(\"0.\" + perc);\n        return new Percentile(latencies, percentile);\n    }\n\n    private static @Nullable LatencyModifier parseLatencyModifier(String spec, Matcher m, LatencyModifierFactory modifiers)\n    {\n        String mod = m.group(\"mod\");\n        String modkind = m.group(\"modkind\");\n        double modifier = 1.0;\n        if (mod != null) modifier = Double.parseDouble(mod);\n        else if (modkind == null) return null;\n        else if (!modkind.startsWith(\"*\"))\n            throw new IllegalArgumentException(\"Invalid latency modifier specification: \" + spec + \". Expect constant factor as base for exponent.\");\n\n        if (modkind == null)\n            return modifiers.multiply(modifier);\n\n        if (modkind.startsWith(\"*\"))\n            return modifiers.multiplyByAttempts(modifier);\n        else if (modkind.startsWith(\"^\"))\n            return modifiers.multiplyByAttemptsExp(modifier);\n        else\n            throw new IllegalArgumentException(\"Unrecognised attempt modifier: \" + modkind);\n    }\n\n    static long saturatedCast(double v)\n    {\n        if (v > Long.MAX_VALUE)\n            return Long.MAX_VALUE;\n        return (long) v;\n    }","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/TimeoutStrategy.java#L303-L339","documentation":"Thrown by TimeoutStrategy.parseLatencyModifier when a latency modifier clause in a timeout specification begins with a modifier kind that is neither null nor a '*' factor; only constant factors (base for exponent) are accepted at this position.","triggerScenarios":"Passing a timeout/latency spec string whose modifier segment uses an unsupported prefix, e.g. '^' alone or other characters, where a plain numeric factor or '*' factor is expected.","commonSituations":"Hand-editing cassandra timeout config strings (e.g. read/request timeout expressions) with invalid modifier syntax; confusing '^' (attempts exponent) with the base factor position.","solutions":["Use a plain numeric constant (e.g. '2') or a '*'-prefixed factor (e.g. '*2') for the modifier.","Move the '^' exponent syntax to the attempts-modifier position where it is accepted.","Check the spec against the PARSE regex pattern documented in TimeoutStrategy."],"exampleFix":"// before\nString spec = \"fixed*^2\"; // invalid: '^' where a factor is expected\n// after\nString spec = \"fixed*2\";   // or use '...^2' in the attempts-modifier position","handlingStrategy":"validation","validationCode":"if (spec != null && spec.matches(\".*[^*\\d.]\\^?.*\")) { /* validate against PARSE regex before passing */ }\n// simpler: reject '^' at the modifier position\njava.util.regex.Pattern p = java.util.regex.Pattern.compile(\".*\\\\*?\\\\d+(\\\\.\\\\d+)?$\");","typeGuard":null,"tryCatchPattern":"try { TimeoutStrategy.parse(spec, latencies); }\ncatch (IllegalArgumentException e) { if (e.getMessage().contains(\"Invalid latency modifier\")) { /* correct modifier syntax */ } throw e; }","preventionTips":["Use plain numbers or '*' factors at the modifier position","Reserve '^' for the attempts-modifier position only","Test spec strings in a staging config first"],"tags":["cassandra","configuration","timeout","parse-error"],"backgroundTag":"invalid-config-value","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"}