{"record":{"id":"f238e0aa5da1fa46","repo":"apache/cassandra","slug":"simplestrategy-requires-a-replication-factor-strat","errorCode":null,"errorMessage":"SimpleStrategy requires a replication_factor strategy option.","messagePattern":"SimpleStrategy requires a replication_factor strategy option\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/SimpleStrategy.java","lineNumber":128,"sourceCode":"            InetAddressAndPort ep = endpoints.endpoint(owner);\n            if (!replicas.endpoints().contains(ep))\n                replicas.add(new Replica(ep, replicaRange, replicas.size() < rf.fullReplicas));\n        }\n\n        return replicas.build();\n    }\n\n\n    @Override\n    public ReplicationFactor getReplicationFactor()\n    {\n        return rf;\n    }\n\n    private static void validateOptionsInternal(Map<String, String> configOptions) throws ConfigurationException\n    {\n        if (configOptions.get(REPLICATION_FACTOR) == null)\n            throw new ConfigurationException(\"SimpleStrategy requires a replication_factor strategy option.\");\n    }\n\n    @Override\n    public void validateOptions() throws ConfigurationException\n    {\n        validateOptionsInternal(configOptions);\n        validateReplicationFactor(configOptions.get(REPLICATION_FACTOR));\n    }\n\n    @Override\n    public void maybeWarnOnOptions(ClientState state)\n    {\n        if (!SchemaConstants.isSystemKeyspace(keyspaceName))\n        {\n            int nodeCount = StorageService.instance.getHostIdToEndpoint().size();\n            // nodeCount==0 on many tests\n            Guardrails.minimumReplicationFactor.guard(rf.fullReplicas, keyspaceName, false, state);\n            Guardrails.maximumReplicationFactor.guard(rf.fullReplicas, keyspaceName, false, state);","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/SimpleStrategy.java#L110-L146","documentation":"SimpleStrategy places replicas with a single flat replication_factor and therefore requires exactly that option in the replication map. validateOptionsInternal throws this ConfigurationException when the 'replication_factor' key is absent, because the strategy cannot determine how many replicas to place.","triggerScenarios":"CREATE/ALTER KEYSPACE ... replication = {'class':'SimpleStrategy'} (or with no 'replication_factor' key) submitted via cqlsh, driver schema metadata, or programmatic KeyspaceMetadata construction.","commonSituations":"Copy-pasting NetworkTopologyStrategy-style per-DC options with SimpleStrategy; drivers generating schema without replication_factor; hand-edited migration scripts; restoring schema dumps that dropped the option.","solutions":["Add the replication_factor option: {'class':'SimpleStrategy','replication_factor':3}","Re-run the CREATE/ALTER KEYSPACE statement with the corrected replication map","If multi-DC is intended, switch to NetworkTopologyStrategy with per-DC factors instead"],"exampleFix":"// before\nCREATE KEYSPACE ks WITH replication = {'class':'SimpleStrategy'};\n// after\nCREATE KEYSPACE ks WITH replication = {'class':'SimpleStrategy','replication_factor':3};","handlingStrategy":"validation","validationCode":"if (\"SimpleStrategy\".equals(opts.get(\"class\")) && !opts.containsKey(\"replication_factor\"))\n    throw new IllegalArgumentException(\"SimpleStrategy requires a replication_factor option\");","typeGuard":null,"tryCatchPattern":"try { session.execute(createKeyspaceCql); }\ncatch (InvalidQueryException e) { if (e.getMessage().contains(\"requires a replication_factor\")) { /* append replication_factor and retry */ } }","preventionTips":["Always include replication_factor with SimpleStrategy","Use shared keyspace-definition templates reviewed in code review","Generate schema from typed builders rather than raw string maps"],"tags":["configuration","replication","missing-option"],"backgroundTag":"missing-required-option","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"}