{"record":{"id":"914527c2f4dfbbbe","repo":"apache/cassandra","slug":"s-is-not-valid-for-s","errorCode":null,"errorMessage":"%s is not valid for %s","messagePattern":"(.+?) is not valid for (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java","lineNumber":101,"sourceCode":"\n    public TimeWindowCompactionStrategyOptions()\n    {\n        sstableWindowUnit = DEFAULT_COMPACTION_WINDOW_UNIT;\n        timestampResolution = DEFAULT_TIMESTAMP_RESOLUTION;\n        sstableWindowSize = DEFAULT_COMPACTION_WINDOW_SIZE;\n        expiredSSTableCheckFrequency = TimeUnit.MILLISECONDS.convert(DEFAULT_EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS, TimeUnit.SECONDS);\n        ignoreOverlaps = DEFAULT_UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION;\n        stcsOptions = new SizeTieredCompactionStrategyOptions();\n    }\n\n    public static Map<String, String> validateOptions(Map<String, String> options, Map<String, String> uncheckedOptions) throws  ConfigurationException\n    {\n        String optionValue = options.get(TIMESTAMP_RESOLUTION_KEY);\n        try\n        {\n            if (optionValue != null)\n                if (!validTimestampTimeUnits.contains(TimeUnit.valueOf(optionValue)))\n                    throw new ConfigurationException(String.format(\"%s is not valid for %s\", optionValue, TIMESTAMP_RESOLUTION_KEY));\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new ConfigurationException(String.format(\"%s is not valid for %s\", optionValue, TIMESTAMP_RESOLUTION_KEY));\n        }\n\n\n        optionValue = options.get(COMPACTION_WINDOW_UNIT_KEY);\n        try\n        {\n            if (optionValue != null)\n                if (!validWindowTimeUnits.contains(TimeUnit.valueOf(optionValue)))\n                    throw new ConfigurationException(String.format(\"%s is not valid for %s\", optionValue, COMPACTION_WINDOW_UNIT_KEY));\n\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new ConfigurationException(String.format(\"%s is not valid for %s\", optionValue, COMPACTION_WINDOW_UNIT_KEY), e);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java#L83-L119","documentation":"ConfigurationException thrown by TimeWindowCompactionStrategyOptions.validateOptions when the timestamp_resolution option is not one of the accepted time units (seconds, milliseconds, minutes, hours) or is not a valid TimeUnit name at all. The same message is used both when the value parses to a TimeUnit that isn't in the valid set and when TimeUnit.valueOf throws IllegalArgumentException for an unknown name.","triggerScenarios":"CREATE/ALTER TABLE with {'class':'TimeWindowCompactionStrategy','timestamp_resolution':'MICROSECONDS'} (valid TimeUnit, not in validTimestampTimeUnits) or 'timestamp_resolution':'sec' (not a TimeUnit constant, caught as IllegalArgumentException).","commonSituations":"Choosing an unsupported resolution like DAYS or MICROSECONDS; abbreviating unit names ('secs'); copy-pasting options from a different system that accepts arbitrary ChronoUnit names.","solutions":["Set timestamp_resolution to one of SECONDS, MILLISECONDS, MINUTES or HOURS (default MILLISECONDS).","Remove the option to use the default resolution.","Match the resolution to how the table's write timestamp is actually generated."],"exampleFix":"// before\n{'class':'TimeWindowCompactionStrategy','timestamp_resolution':'MICROSECONDS'}\n// after\n{'class':'TimeWindowCompactionStrategy','timestamp_resolution':'MILLISECONDS'}","handlingStrategy":"validation","validationCode":"Set<String> valid = Set.of(\"SECONDS\",\"MILLISECONDS\",\"MINUTES\",\"HOURS\");\nif (opts.containsKey(\"timestamp_resolution\") && !valid.contains(opts.get(\"timestamp_resolution\"))) throw new IllegalArgumentException(\"timestamp_resolution must be one of \" + valid);","typeGuard":null,"tryCatchPattern":"try { schema.alterTable(cql); } catch (ConfigurationException e) { if (e.getMessage().contains(\"TIMESTAMP_RESOLUTION_KEY\")) { /* use a valid unit name and retry */ } else throw e; }","preventionTips":["Only use SECONDS, MILLISECONDS, MINUTES or HOURS — not arbitrary TimeUnit constants.","Match the resolution to the timestamp source of the table (usually MILLISECONDS).","Keep option values exact-case uppercase TimeUnit names."],"tags":["compaction","twcs","configuration"],"backgroundTag":"invalid-enum-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"}