{"record":{"id":"09ad99deaf6e9ff3","repo":"apache/cassandra","slug":"unsupported-time-unit-s-supported-units-are-s","errorCode":null,"errorMessage":"Unsupported time unit: %s. Supported units are: %s","messagePattern":"Unsupported time unit: (.+?)\\. Supported units are: (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DurationSpec.java","lineNumber":163,"sourceCode":"\n    /**\n     * @param symbol the time unit symbol\n     * @return the time unit associated to the specified symbol\n     */\n    public static TimeUnit fromSymbol(String symbol)\n    {\n        switch (toLowerCaseLocalized(symbol))\n        {\n            case \"d\": return DAYS;\n            case \"h\": return HOURS;\n            case \"m\": return MINUTES;\n            case \"s\": return SECONDS;\n            case \"ms\": return MILLISECONDS;\n            case \"us\":\n            case \"µs\": return MICROSECONDS;\n            case \"ns\": return TimeUnit.NANOSECONDS;\n        }\n        throw new IllegalArgumentException(String.format(\"Unsupported time unit: %s. Supported units are: %s\",\n                                                       symbol, Arrays.stream(TimeUnit.values())\n                                                                     .map(DurationSpec::symbol)\n                                                                     .collect(Collectors.joining(\", \"))));\n    }\n\n    /**\n     * @param targetUnit the time unit\n     * @return this duration in the specified time unit\n     */\n    public long to(TimeUnit targetUnit)\n    {\n        return targetUnit.convert(quantity, unit);\n    }\n\n    @Override\n    public int hashCode()\n    {\n        // Milliseconds seems to be a reasonable tradeoff","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DurationSpec.java#L145-L181","documentation":"IllegalArgumentException from DurationSpec.fromSymbol: the given unit symbol did not match any supported time-unit suffix (d, h, m, s, ms, us/µs, ns — matched case-insensitively). It is the terminal guard of the symbol switch and fires when parsing a duration string's unit portion anywhere a DurationSpec is constructed.","triggerScenarios":"A duration string whose unit portion fails the switch, e.g. '5w', '5H', '5 min', '5sec', or a multi-byte lookalike for 'µs'.","commonSituations":"Using units from other ecosystems (w for weeks, m confused with min); uppercase units; unicode issues typing µ.","solutions":["Use one of the supported symbols exactly: d, h, m, s, ms, us, µs, ns","Convert unsupported units (e.g. 1w -> 7d)","Ensure lowercase ASCII 'us' if the micro symbol is problematic"],"exampleFix":"// before\n retention = \"4w\";\n// after\n retention = \"28d\";","handlingStrategy":"validation","validationCode":"private static final Set<String> UNITS = Set.of(\"d\",\"h\",\"m\",\"s\",\"ms\",\"us\",\"µs\",\"ns\");\nstatic void checkUnit(String v) {\n    String unit = v.replaceAll(\"^\\\\d+\", \"\");\n    if (!UNITS.contains(unit)) throw new IllegalArgumentException(\"Unsupported unit: \" + unit);\n}","typeGuard":null,"tryCatchPattern":"try {\n    spec = new MyDurationSpec(\"4w\");\n} catch (IllegalArgumentException e) {\n    logger.error(\"Unsupported time unit: {}\", e.getMessage());\n}","preventionTips":["Restrict config to the 8 supported symbols","Convert weeks/fortnights to days before configuring","Beware unicode lookalikes of µ; prefer ASCII 'us'"],"tags":["duration","unit","validation"],"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-14T16:17:12.679Z"}