{"record":{"id":"b7d7f44153261dcf","repo":"apache/cassandra","slug":"unable-to-use-given-strategy-class-localstrategy-b7d7f4","errorCode":null,"errorMessage":"Unable to use given strategy class: LocalStrategy is reserved for internal use.","messagePattern":"Unable to use given strategy class: LocalStrategy is reserved for internal use\\.","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java","lineNumber":104,"sourceCode":"        Keyspaces schema = metadata.schema.getKeyspaces();\n        if (schema.containsKeyspace(keyspaceName))\n        {\n            if (ifNotExists)\n                return schema;\n\n            throw new AlreadyExistsException(keyspaceName);\n        }\n\n        // we deduplicate ReplicationParams here to use the same objects in KeyspaceMetadata\n        // as we have as keys in metadata.placements to have a fast map lookup\n        // ReplicationParams are immutable, so it is a safe optimization\n        KeyspaceParams keyspaceParams = attrs.asNewKeyspaceParams();\n        ReplicationParams replicationParams = metadata.placements().deduplicateReplicationParams(keyspaceParams.replication);\n        keyspaceParams = keyspaceParams.withSwapped(replicationParams);\n        KeyspaceMetadata keyspaceMetadata = KeyspaceMetadata.create(keyspaceName, keyspaceParams);\n\n        if (keyspaceMetadata.params.replication.klass.equals(LocalStrategy.class))\n            throw ire(\"Unable to use given strategy class: LocalStrategy is reserved for internal use.\");\n\n        if (keyspaceMetadata.params.replication.isMeta())\n            throw ire(\"Can not create a keyspace with MetaReplicationStrategy\");\n\n        keyspaceMetadata.params.validate(keyspaceName, state, metadata);\n        keyspaceMetadata.replicationStrategy.validateExpectedOptions(metadata);\n\n        expandedCql = keyspaceMetadata.toCqlString(false, true, ifNotExists);\n        verifyExpandedCql(expandedCql);\n        return schema.withAddedOrUpdated(keyspaceMetadata);\n    }\n\n    SchemaChange schemaChangeEvent(KeyspacesDiff diff)\n    {\n        return new SchemaChange(Change.CREATED, keyspaceName);\n    }\n\n    public void authorize(ClientState client)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/CreateKeyspaceStatement.java#L86-L122","documentation":"LocalStrategy is reserved for internal (system) keyspaces only. A CREATE KEYSPACE explicitly specifying class LocalStrategy is rejected to prevent users from creating user keyspaces whose data is replicated locally-only and managed by the system.","triggerScenarios":"`CREATE KEYSPACE ks WITH replication = {'class': 'LocalStrategy'};` — detected after building KeyspaceMetadata in apply().","commonSituations":"Copying the replication settings from a system keyspace (system, system_schema) into a user keyspace; misunderstanding LocalStrategy as a \"replication_factor=1\" equivalent.","solutions":["Use SimpleStrategy or NetworkTopologyStrategy for user keyspaces.","For a single-node-local feel, use SimpleStrategy with replication_factor: 1 instead.","If the intent was per-datacenter behavior, use NetworkTopologyStrategy with explicit RF per DC."],"exampleFix":"// before\nCREATE KEYSPACE ks WITH replication = {'class': 'LocalStrategy'};\n\n// after\nCREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};","handlingStrategy":"validation","validationCode":"String cls = extractReplicationClass(cql); if (\"LocalStrategy\".equals(cls)) throw new IllegalArgumentException(\"LocalStrategy is reserved for internal use\");","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidQueryException e) { if (e.getMessage().contains(\"LocalStrategy is reserved\")) { /* swap to SimpleStrategy/NetworkTopologyStrategy */ } else throw e; }","preventionTips":["Never copy replication settings from system_schema/system keyspaces","Allow-list only SimpleStrategy and NetworkTopologyStrategy in tooling","Document that LocalStrategy is internal-only"],"tags":["cassandra","cql","keyspace","replication","internal"],"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"}