{"record":{"id":"ab90645be39c3170","repo":"apache/cassandra","slug":"invalid-value-s-for-caching-sub-option-s-on","errorCode":null,"errorMessage":"Invalid value '%s' for caching sub-option '%s': only '%s' and '%s' are allowed","messagePattern":"Invalid value '(.+?)' for caching sub-option '(.+?)': only '(.+?)' and '(.+?)' are allowed","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/CachingParams.java","lineNumber":130,"sourceCode":"    }\n\n    public Map<String, String> asMap()\n    {\n        return ImmutableMap.of(Option.KEYS.toString(),\n                               keysAsString(),\n                               Option.ROWS_PER_PARTITION.toString(),\n                               rowsPerPartitionAsString());\n    }\n\n    private static boolean keysFromString(String value)\n    {\n        if (value.equalsIgnoreCase(ALL))\n            return true;\n\n        if (value.equalsIgnoreCase(NONE))\n            return false;\n\n        throw new ConfigurationException(format(\"Invalid value '%s' for caching sub-option '%s': only '%s' and '%s' are allowed\",\n                                                value,\n                                                Option.KEYS,\n                                                ALL,\n                                                NONE));\n    }\n\n    String keysAsString()\n    {\n        return cacheKeys ? ALL : NONE;\n    }\n\n    private static int rowsPerPartitionFromString(String value)\n    {\n        if (value.equalsIgnoreCase(ALL))\n            return Integer.MAX_VALUE;\n\n        if (value.equalsIgnoreCase(NONE))\n            return 0;","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/CachingParams.java#L112-L148","documentation":"The 'keys' caching sub-option only accepts the literal strings 'ALL' or 'NONE' (case-insensitive). keysFromString throws MarshalException-style ConfigurationException for any other value while parsing the option during CREATE/ALTER TABLE.","triggerScenarios":"CREATE TABLE ... WITH caching = {'keys': 'all_keys'} or {'keys': 'true'} — any value other than ALL/NONE passed to the keys sub-option.","commonSituations":"Developers coming from older Cassandra (<3.0) where caching was {'keys': 'ALL', 'rows_per_partition': 'NONE'} vs boolean-style or from KeyCache terminology, typing values like 'KEYS_ONLY' or 'TRUE'.","solutions":["Use 'ALL' or 'NONE' (case-insensitive) for the 'keys' sub-option","Remove the 'keys' sub-option to inherit the default"],"exampleFix":"// before\ncaching = {'keys': 'true'}\n// after\ncaching = {'keys': 'ALL'}","handlingStrategy":"validation","validationCode":"String v = cachingMap.get(\"keys\");\nif (v != null && !(v.equalsIgnoreCase(\"ALL\") || v.equalsIgnoreCase(\"NONE\"))) throw new IllegalArgumentException(\"keys must be ALL or NONE\");","typeGuard":"boolean isValidKeysOption(String v) { return \"ALL\".equalsIgnoreCase(v) || \"NONE\".equalsIgnoreCase(v); }","tryCatchPattern":"try { session.execute(ddl); } catch (InvalidQueryException e) { if (e.getMessage().contains(\"caching sub-option 'keys'\")) { /* normalize to ALL/NONE and retry */ } else throw e; }","preventionTips":["Normalize booleans/old syntax to ALL/NONE before generating DDL","Use case-insensitive checks on your side, Cassandra's check is case-insensitive","Keep a single constants list of legal caching values in schema tooling"],"tags":["cassandra","schema","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-14T16:17:12.679Z"}