{"record":{"id":"cb0977c2ad6800a9","repo":"apache/cassandra","slug":"invalid-configuration-s-should-be-positive-d","errorCode":null,"errorMessage":"Invalid configuration, %s should be positive: %d","messagePattern":"Invalid configuration, (.+?) should be positive: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compaction/unified/Controller.java","lineNumber":502,"sourceCode":"    }\n\n    public static Map<String, String> validateOptions(Map<String, String> options) throws ConfigurationException\n    {\n        options = new HashMap<>(options);\n        String s;\n\n        s = options.remove(SCALING_PARAMETERS_OPTION);\n        if (s != null)\n            parseScalingParameters(s);\n\n        s = options.remove(BASE_SHARD_COUNT_OPTION);\n        if (s != null)\n        {\n            try\n            {\n                int numShards = Integer.parseInt(s);\n                if (numShards <= 0)\n                    throw new ConfigurationException(String.format(\"Invalid configuration, %s should be positive: %d\",\n                                                                   BASE_SHARD_COUNT_OPTION,\n                                                                   numShards));\n            }\n            catch (NumberFormatException e)\n            {\n                throw new ConfigurationException(String.format(\"%s is not a parsable int (base10) for %s\",\n                                                               s,\n                                                               BASE_SHARD_COUNT_OPTION), e);\n            }\n        }\n\n        // preserve the configuration for later use during min_sstable_size.\n        long targetSSTableSize = DEFAULT_TARGET_SSTABLE_SIZE;\n        s = options.remove(TARGET_SSTABLE_SIZE_OPTION);\n        if (s != null)\n        {\n            try\n            {","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/unified/Controller.java#L484-L520","documentation":"UnifiedCompactionStrategy's Controller.validateOptions parses base_shard_count and requires a strictly positive integer, since the number of shards per level must divide data into at least one shard. Zero or negative values throw ConfigurationException with the parsed number.","triggerScenarios":"validateOptions with base_shard_count='0', '-4', or any value that parses as int but is <= 0 (non-numeric values hit error 888 instead).","commonSituations":"Setting base_shard_count to 0 believing it means 'auto' or 'disabled'; negative sentinels from tooling; copy-paste from configs of other strategies.","solutions":["Set base_shard_count to a positive integer, e.g. '4'","Remove the option to use the default (1 shard)","Choose shard counts based on expected data size per node per level","Catch ConfigurationException when applying table options"],"exampleFix":"// before\n'base_shard_count': '0'\n// after\n'base_shard_count': '4'","handlingStrategy":"validation","validationCode":"if (opts.containsKey(\"base_shard_count\") && Integer.parseInt(opts.get(\"base_shard_count\").trim()) <= 0)\n    throw new IllegalArgumentException(\"base_shard_count must be a positive integer\");","typeGuard":"static boolean isPositiveInt(String s) { if (s == null) return false; try { return Integer.parseInt(s.trim()) > 0; } catch (NumberFormatException e) { return false; } }","tryCatchPattern":"try {\n    session.execute(alterStmt);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"should be positive\")) { /* fix base_shard_count */ }\n    throw e;\n}","preventionTips":["Omit base_shard_count (defaults to 1) rather than passing 0 for 'auto'","Size shard counts to node data volume per UCS guidance","Reject non-positive shard counts in config validators"],"tags":["cassandra","configuration","compaction","ucs","sharding"],"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-14T16:17:12.679Z"}