{"record":{"id":"5c9d685cb1bd3b14","repo":"apache/cassandra","slug":"unable-to-use-given-strategy-class-localstrategy","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/AlterKeyspaceStatement.java","lineNumber":101,"sourceCode":"        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n        if (null == keyspace)\n        {\n            if (!ifExists)\n                throw ire(\"Keyspace '%s' doesn't exist\", keyspaceName);\n            return schema;\n        }\n\n        KeyspaceMetadata newKeyspace = keyspace.withSwapped(attrs.asAlteredKeyspaceParams(keyspace.params));\n\n        if (attrs.getReplicationStrategyClass() != null && attrs.getReplicationStrategyClass().equals(SimpleStrategy.class.getSimpleName()))\n            Guardrails.simpleStrategyEnabled.ensureEnabled(state);\n\n        if (keyspace.params.replication.isMeta() && !keyspace.name.equals(SchemaConstants.METADATA_KEYSPACE_NAME))\n            throw ire(\"Can not alter a keyspace to use MetaReplicationStrategy\");\n\n        if (newKeyspace.params.replication.klass.equals(LocalStrategy.class))\n            throw ire(\"Unable to use given strategy class: LocalStrategy is reserved for internal use.\");\n\n        newKeyspace.params.validate(keyspaceName, state, metadata);\n        newKeyspace.replicationStrategy.validate(metadata);\n\n        validateNoRangeMovements();\n        validateTransientReplication(keyspace, newKeyspace);\n\n        // Because we used to not properly validate unrecognized options, we only log a warning if we find one.\n        try\n        {\n            newKeyspace.replicationStrategy.validateExpectedOptions(metadata);\n        }\n        catch (ConfigurationException e)\n        {\n            logger.warn(\"Ignoring {}\", e.getMessage());\n        }\n\n        return schema.withAddedOrUpdated(newKeyspace);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/AlterKeyspaceStatement.java#L83-L119","documentation":"The ALTER KEYSPACE would set the replication strategy class to LocalStrategy, which is reserved for internal system keyspaces and cannot be assigned by users. apply() compares the new keyspace's replication klass to LocalStrategy and throws.","triggerScenarios":"`ALTER KEYSPACE ks WITH replication = {'class':'LocalStrategy'}` (or copying params from an internal keyspace like system_auth's LocalStrategy-based cousins).","commonSituations":"Copying replication settings from a system keyspace verbatim; typos or misconfigured migration tooling emitting LocalStrategy.","solutions":["Use SimpleStrategy or NetworkTopologyStrategy instead of LocalStrategy","Remove the replication-class override inherited from system keyspace templates","Re-run the DDL with an allowed strategy class"],"exampleFix":"// before\nALTER KEYSPACE ks WITH replication = {'class':'LocalStrategy'};\n// after\nALTER KEYSPACE ks WITH replication = {'class':'NetworkTopologyStrategy','dc1':3};","handlingStrategy":"validation","validationCode":"String cls = replicationOptions.get(\"class\"); if (cls != null && cls.endsWith(\"LocalStrategy\")) throw new IllegalArgumentException(\"LocalStrategy is reserved for internal use\");","typeGuard":null,"tryCatchPattern":"try { session.execute(alterCql); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"LocalStrategy\")) { /* switch to NetworkTopologyStrategy and retry */ } else throw e; }","preventionTips":["Validate replication options before issuing ALTER KEYSPACE","Whitelist only SimpleStrategy and NetworkTopologyStrategy in tooling","Do not copy replication settings from system keyspaces"],"tags":["cql","keyspace","replication","strategy-class"],"backgroundTag":"invalid-argument-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"}